Take a look at Log::Dispatch
Dispatches messages to one or more outputs.
use Log::Dispatch;
# Simple API
#
my $log =
Log::Dispatch->new
( outputs =>
[ [ 'File', min_level => 'debug', filename => 'logfile' ],
[ 'Screen', min_level => 'warning' ],
],
);
$log->info('Blah, blah');
# More verbose API
#
my $log = Log::Dispatch->new();
$log->add( Log::Dispatch::File->new
( name => 'file1',
min_level => 'debug',
filename => 'logfile'
)
);
$log->add( Log::Dispatch::Screen->new
( name => 'screen',
min_level => 'warning',
)
);
$log->log( level => 'info', message => 'Blah, blah' );
my $sub = sub { my %p = @_; return reverse $p{message}; };
my $reversing_dispatcher = Log::Dispatch->new( callbacks => $sub );
It has a few helper/utility modules you should look at too.
Log::Dispatch::DBI - Log output to a database table.
Log::Dispatch::FileRotate - Rotates log files periodically as part of its
usage.
Log::Dispatch::File::Stamped - Stamps log
files with date and time information.
Log::Dispatch::Jabber - Logs
messages via Jabber.
Log::Dispatch::Tk - Logs
messages to a Tk window.
Log::Dispatch::Win32EventLog - Logs
messages to the Windows event log.
Log::Dispatch::Config - Allows
configuration of logging via a text
file similar (or so I'm told) to how
it is done with log4j.