Catalyst::Log::Log4perl(3pm) | User Contributed Perl Documentation | Catalyst::Log::Log4perl(3pm) |
Catalyst::Log::Log4perl - DEPRECATED (see Log::Log4perl::Catalyst)
In MyApp.pm:
use Catalyst::Log::Log4perl; # then we create a custom logger object for catalyst to use. # If we don't 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.
The second (optional) parameter is a hash with extra options. Currently three 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 'override_cspecs' - EXPERIMENTAL Set it to a true value to locally override some parts of L<Log::Log4perl::Layout::PatternLayout>. See L<OVERRIDING CSPECS> below
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.
Due to some fundamental design incompatibilities of Log::Log4perl and Catalyst::Log all cspecs of Log::Log4perl::Layout::PatternLayout that rely on call stack information fail to work as expected. Affected are the format strings %L, %F, %C, %M, %l and %T. You can instruct Catalyst::Log::Log4perl to try to hijack these patterns which seems to work reasonable well, but be advised that this feature is HIGHLY EXPERIMENTAL and relies on a few internals of Log::Log4perl that might change in later versions of this library. Additionally, this feature is currently only tested with Log::Log4perl version 1.08 allthough the underlying internals of Log::Log4perl seem to be stable since at least version 0.47.
The %T cspec of Log::Log4perl::Layout::PatternLayout is currently unimplemented. The implementation to get %M defies any logical approach but seems to work perfectly.
Log::Log4perl, Catalyst::Log, Catalyst.
Adam Jacob, "adam@stalecoffee.org"
Andreas Marienborg, "omega@palle.net"
Gavin Henry, "ghenry@suretecsystems.com" (Typos)
Sebastian Willert (Overriding CSPECS)
J. Shirley "jshirley@gmail.com" (Adding _dump)
Tomas Doran (t0m) "bobtfish@bobtfish.net" (Current maintainer)
Wallace Reis (wreis) "wreis@cpan.org"
Copyright (c) 2005 - 2009 the Catalyst::Log::Log4perl "AUTHORS" as listed above.
This library is free software. You can redistribute it and/or modify it under the same terms as perl itself.
2021-01-04 | perl v5.32.0 |