++ed by:
Edward Ash


    package MyApp;
    use Moo;
    with 'MooX::Log::Any';
    sub something {
        my ($self) = @_;
        $self->log->debug("started bar");    ### logs with default class catergory "MyApp"
        $self->log->error("started bar");    ### logs with default class catergory "MyApp"


A logging role building a very lightweight wrapper to Log::Any for use with your Moo or Moose classes. Connectibng a Log::Any::Adapter should be performed prior to logging the first log message, otherwise nothing will happen, just like with Log::Any

Using the logger within a class is as simple as consuming a role:

    package MyClass;
    use Moo;
    with 'MooX::Log::Any';
    sub dummy {
        my $self = shift;
        $self->log->info("Dummy log entry");

The logger needs to be setup before using the logger, which could happen in the main application:

    package main;
    use Log::Any::Adapter;
    # Send all logs to Log::Log4perl
    use MyClass;
    my $myclass = MyClass->new();
    $myclass->log->info("In my class"); # Access the log of the object
    $myclass->dummy;                    # Will log "Dummy log entry"



The log attribute holds the Log::Any::Adapter object that implements all logging methods for the defined log levels, such as debug or error. As this method is defined also in other logging roles/systems like MooseX::Log::LogDispatch this can be thought of as a common logging interface.

  package MyApp::View::JSON;

  extends 'MyApp::View';
  with 'MooseX:Log::Log4perl';

  sub bar {
    $self->logger->info("Everything fine so far");    # logs a info message
    $self->logger->debug("Something is fishy here");  # logs a debug message


This is an alias for log.


Log::Any, Moose, Moo


Please report any bugs or feature requests to bug-moosex-log4perl@rt.cpan.org, or through the web interface at http://rt.cpan.org.

Or come bother us in #moose on irc.perl.org.


Roland Lammel <lammel@cpan.org>

Inspired by the work by Chris Prather <perigrin@cpan.org> and Ash Berlin <ash@cpan.org> on MooseX::LogDispatch and Roland Lammel <lammel@cpan.org> =head1 CONTRIBUTORS

In alphabetical order:

Hosting generously
sponsored by Bytemark