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.
The constructor new() opens a file, specified in filename, for writing. If mode is append, it will append to the file if it exists, on other settings of mode it will clobber any existing file first. The default mode is append.
new()
filename
mode
append
autoflush, if set to a true value, triggers flushing the data out to the file on every call to log().
autoflush
log()
The 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.
Design and implementation of this module has been greatly inspired by Dave Rolsky's Log::Dispatch appender framework.
Log::Dispatch
Mike Schilli <log4perl@perlmeister.com>, 2003
To install Log::Log4perl, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Log::Log4perl
CPAN shell
perl -MCPAN -e shell install Log::Log4perl
For more information on module installation, please visit the detailed CPAN module installation guide.