---
name: "MooseX::Log::Log4perl::Easy"
section: "3pm"
platform: "linux"
package: "libmoosex-log-log4perl-perl"
version: "0.47-2"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/MooseX::Log::Log4perl::Easy"
---

# MooseX::Log::Log4perl::Easy(3pm)

A role for easy usage of logging in your Moose based modules based on MooseX::Log::Log4perl

## NAME

MooseX::Log::Log4perl::Easy - A role for easy usage of logging in your Moose based modules based on MooseX::Log::Log4perl

## SYNOPSIS

```
 package MyApp;
 use Moose;
 use Log::Log4perl qw(:easy);
 with 'MooseX::Log::Log4perl::Easy';
 BEGIN {
         Log::Log4perl->easy_init();
 }
 sub foo {
   my ($self) = @_;
   $self->log_debug("started bar");            ### logs with default class catergory "MyApp"
   $self->log_info('bar');                     ### logs an info message
   $self->log('AlsoPossible')->fatal("croak"); ### log
 }
```

## DESCRIPTION

The "Easy" logging role based on the MooseX::Log::Log4perl logging role for Moose directly adds the log methods for all available levels to your class instance. Hence it is possible to use

```
  $self->log_info("blabla");
```

without having to access a separate log attribute as in MooseX::Log::Log4perl;

In case your app grows and you need more of the super-cow powers of Log4perl or simply don't want the additional methods to clutter up your class you can simply replace all code `"$self->log_LEVEL"` with `"$self->log->LEVEL"`.

You can use the following regex substitution to accomplish that:

```
  s/log(_(trace|debug|info|warn|error|fatal))/log->$2/g
```

## ACCESSORS

### logger

See MooseX::Log::Log4perl

### log

See MooseX::Log::Log4perl

### log\_fatal ($msg)

Logs a fatal message `$msg` using the logger attribute. Same as calling

```
  $self->logger->fatal($msg)
```

### log\_error ($msg)

Logs an error message using the logger attribute. Same as calling

```
  $self->logger->error($msg)
```

### log\_warn ($msg)

Logs a warn message using the logger attribute. Same as calling

```
  $self->logger->warn($msg)
```

### log\_info ($msg)

Logs an info message using the logger attribute. Same as calling

```
  $self->logger->info($msg)
```

### log\_debug ($msg)

Logs a debug message using the logger attribute. Same as calling

```
  $self->logger->debug($msg)
```

### log\_trace ($msg)

Logs a trace message using the logger attribute. Same as calling

```
  $self->logger->trace($msg)
```

## SEE ALSO

MooseX::Log::Log4perl

## AUTHOR

Roland Lammel `"<lammel@cpan.org>"`

## LICENSE AND COPYRIGHT

Copyright (c) 2008-2016, Roland Lammel \<lammel@cpan.org\>, http://www.quikit.at

This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic.
