Log::Log4perl::Appender::File - Log to file


NAME

Log::Log4perl::Appender::File - Log to file


SYNOPSIS

    use Log::Log4perl::Appender::File;
    my $app = Log::Log4perl::Appender::File->new(
      filename  => 'file.log',
      mode      => 'append',
      autoflush => 1,
      umask     => 0222,
    );
    $file->log(message => "Log me\n");


DESCRIPTION

This is a simple appender for writing to a file.

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.

If you want to switch over to a different logfile, use the file_switch($newfile) method which will first close the old file handle and then open a one to the new file specified.

OPTIONS

filename
Name of the log file.

mode
Messages will be append to the file if $mode is set to the string "append". Will clobber the file if set to "clobber". If it is "pipe", the file will be understood as executable to pipe output to. Default mode is "append".

autoflush
autoflush, if set to a true value, triggers flushing the data out to the file on every call to log(). autoflush is on by default.

umask
Specifies the umask to use when creating the file, determining the file's permission settings. If set to 0222 (default), new files will be created with rw-r--r-- permissions. If set to 0000, new files will be created with rw-rw-rw- permissions.

utf8
If you're printing out Unicode strings, the output filehandle needs to be set into :utf8 mode:
    my $app = Log::Log4perl::Appender::File->new(
      filename  => 'file.log',
      mode      => 'append',
      utf8      => 1,
    );

binmode
To manipulate the output filehandle via binmode(), use the binmode parameter:
    my $app = Log::Log4perl::Appender::File->new(
      filename  => 'file.log',
      mode      => 'append',
      binmode   => ":utf8",
    );

A setting of ``:utf8'' for binmode is equivalent to specifying the utf8 option (see above).

Design and implementation of this module has been greatly inspired by Dave Rolsky's Log::Dispatch appender framework.


AUTHOR

Mike Schilli <log4perl@perlmeister.com>, 2003, 2005

 Log::Log4perl::Appender::File - Log to file