Log::Dispatch::File::Rolling - Object for logging to date/time/pid |
Log::Dispatch::File::Rolling - Object for logging to date/time/pid stamped files
use Log::Dispatch::File::Rolling;
my $file = Log::Dispatch::File::Rolling->new( name => 'file1', min_level => 'info', filename => 'Somefile%d{yyyyMMdd}.log', mode => 'append' );
$file->log( level => 'emerg', message => "I've fallen and I can't get up\n" );
This module provides an object for logging to files under the Log::Dispatch::* system.
This module subclasses Log::Dispatch::File for logging to date/time stamped files. See the Log::Dispatch::File manpage for instructions on usage. This module differs only on the following three points:
flock()
to lock the file while writing to it.
It is the same tag Log::Log4perl::Layout::PatternLayout uses, see the Log::Log4perl::Layout::PatternLayout manpage, chapter ``Fine-tune the date''. In short: Include a ``%d{...}'' in the filename where ``...'' is a format string according to the SimpleDateFormat in the Java World (http://java.sun.com/j2se/1.3/docs/api/java/text/SimpleDateFormat.html). See also the Log::Log4perl::DateFormat manpage for information about further restrictions.
In addition to the format provided by Log::Log4perl::DateFormat this module also supports '$' for inserting the PID. Repeat the character to define how many character wide the field should be. This should not be needed regularly as this module also supports logfile sharing between processes, but if you've got a high load on your logfile or a system that doesn't support flock()...
-A -C -X -b5.6.1 -nLog::Dispatch::File::Rolling --skip-exporter -v0.99
Now it is working, I also included 4 tests.
the Log::Dispatch::File manpage, the Log::Log4perl::Layout::PatternLayout manpage, http://java.sun.com/j2se/1.3/docs/api/java/text/SimpleDateFormat.html, the Log::Log4perl::DateFormat manpage, 'perldoc -f flock', 'perldoc -f fork'.
M. Jacob, <jacob@j-e-b.net>
Copyright (C) 2003 M. Jacob <jacob@j-e-b.net>
Based on:
Log::Dispatch::File::Stamped by Eric Cholet <cholet@logilune.com> Log::Dispatch::FileRotate by Mark Pfeiffer, <markpf@mlp-consulting.com.au>
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Log::Dispatch::File::Rolling - Object for logging to date/time/pid |