Catalyst::Log::Log4perl - Log::Log4perl logging for Catalyst
In MyApp.pm:
use Catalyst::Log::Log4perl; # then we create a custom logger object for catalyst to use. # If we dont supply any arguments to new, it will work almost # like the default catalyst-logger. __PACKAGE__->log(Catalyst::Log::Log4perl->new()); # But the real power of Log4perl lies in the configuration, so # lets try that. example.conf is included in the distribution, # alongside the README and Changes. __PACKAGE__->log(Catalyst::Log::Log4perl->new('example.conf'));
And later...
$c->log->debug("This is using log4perl!");
This module provides a Catalyst::Log implementation that uses Log::Log4perl as the underlying log mechanism. It provides all the methods listed in Catalyst::Log, with the exception of:
levels enable disable
These methods simply return 0 and do nothing, as similar functionality is already provided by Log::Log4perl.
These methods will all instantiate a logger with the component set to the package who called it. For example, if you were in the MyApp::C::Main package, the following:
package MyApp::C::Main; sub default : Private { my ( $self, $c ) = @_; my $logger = $c->log; $logger->debug("Woot!"); }
Would send a message to the Myapp.C.Main Log::Log4perl component.
See Log::Log4perl for more information on how to configure different logging mechanisms based on the component.
This builds a new Catalyst::Log::Log4perl object. If you provide an argument to new(), it will be passed directly to Log::Log4perl::init.
The second (optional) parameter is a hash with extra options. Currently only two additional parameters are defined:
'autoflush' - Set it to a true value to disable abort(1) support. 'watch_delay' - Set it to a true value to use L<Log::Log4perl>'s init_and_watch
Without any arguments, new() will initialize a root logger with a single appender, Log::Log4perl::Appender::Screen, configured to have an identical layout to the default Catalyst::Log object.
Flushes the cache. Much like the way Catalyst::Log does it.
Causes the current log-object to not log anything, effectivly shutting up this request, making it disapear from the logs.
Passes it's arguments to $logger->debug.
Passes it's arguments to $logger->info.
Passes it's arguments to $logger->warn.
Passes it's arguments to $logger->error.
Passes it's arguments to $logger->fatal.
Calls $logger->is_debug.
Calls $logger->is_info.
Calls $logger->is_warn.
Calls $logger->is_error.
Calls $logger->is_fatal.
This method does nothing but return "0". You should use Log::Log4perl's built in mechanisms for setting up log levels.
This method does nothing but return "0". You should use Log::Log4perl's built in mechanisms for enabling log levels.
This method does nothing but return "0". You should use Log::Log4perl's built in mechanisms for disabling log levels.
Log::Log4perl, Catalyst::Log, Catalyst.
Adam Jacob, adam@stalecoffee.org Andreas Marienborg, omega@palle.net Gavin Henry, ghenry@suretecsystems.com (Typos)
adam@stalecoffee.org
omega@palle.net
ghenry@suretecsystems.com
This library is free software. You can redistribute it and/or modify it under the same terms as perl itself.
To install Catalyst::Log::Log4perl, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Catalyst::Log::Log4perl
CPAN shell
perl -MCPAN -e shell install Catalyst::Log::Log4perl
For more information on module installation, please visit the detailed CPAN module installation guide.