NAME
Log::Log4perl::Appender - Log appender object
SYNOPSIS
use Log::Log4perl::Appender;
# Define a logger
my $logger = Log::Log4perl->get_logger("abc.def.ghi");
# Define a layout
my $layout = Log::Log4perl::Layout::PatternLayout->("%d (%F:%L)> %m");
# Define an appender
my $appender = Log::Log4perl::Appender->new("Log::Dispatch::Screen"
name => 'dumpy');
# Set the appender's layout
$appender->layout($layout);
$logger->add_appender($appender);
DESCRIPTION
This class is a wrapper around the Log::Dispatch::*
collection of dispatchers. It hides the idiosyncrasies of Log::Dispatch
(every dispatcher gotta have a name, but there's no accessor to retrieve it) from Log::Log4perl
and yet re-uses the extremely useful variety of dispatchers already created and tested in Log::Dispatch
.
The constructor new()
takes the name of the Log::Dispatcher
class to be created as a string (!) argument, optionally followed by a number of Log::Dispatcher::Whatever
-specific parameters, for example:
# Define an appender
my $appender = Log::Log4perl::Appender->new("Log::Dispatch::File"
name => 'dumpy',
file => 'out.log');
If no name
parameter is specified, the appender object will create a unique one (format appNNN
), which can be retrieved later via the name()
method:
print "The appender's name is ", $appender->name(), "\n";
The Log::Log4perl::Appender
will relay the log_to()
method to the Log::Dispatch::*
object it carries in its womb and can therefore be used by Log::Log4perl
just like a Log::Dispatch::*
appender.
SEE ALSO
AUTHOR
Mike Schilli, <m@perlmeister.com>