Log::Log4perl::Appender::File - Log to file
use Log::Log4perl::Appender::File; my $app = Log::Log4perl::Appender::File->new( filename => 'file.log', mode => 'append', autoflush => 1, ); $file->log(message => "Log me\n");
This is a simple appender for writing to a file.
new() opens a file, specified in
filename, for writing. If
append, it will append to the file if it exists, if it is
pipe the file will be understood as executable to pipe output to. On other settings of
mode it will clobber any existing file first and then start writing to it. The default
autoflush, if set to a true value, triggers flushing the data out to the file on every call to
log() method takes a single scalar. If a newline character should terminate the message, it has to be added explicitely.
Upon destruction of the object, the filehandle to access the file is flushed and closed.
If you want to switch over to a different logfile, use the
switch_file($newfile) method which will first close the old file handle and then open a one to the new file specified.
Design and implementation of this module has been greatly inspired by Dave Rolsky's
Log::Dispatch appender framework.
Mike Schilli <firstname.lastname@example.org>, 2003