Log::File::Rolling - Log to date/time-stamped files
use Log::File::Rolling; my $logger = Log::File::Rolling->new( filename => 'myapp.%Y-%m-%d.log', current_symlink => 'myapp.log.current', timezone => 'localtime', ); $logger->log("My log message\n");
This module provides an object for logging to files. The log file will be "rolled" over to the next file whenever the filename changes according to the
filename format parameter. When this occurs, an optional
current_symlink file will be pointed to the current file.
This module was forked from the Log::Dispatch::File::Rolling to add the symlink feature and fix a few other minor issues (see the
Changes file for details).
Similar to the original, this module should also have these properties:
This module will close and re-open the logfile after a fork.
This module uses flock() to lock the file while writing to it.
- stamped filenames
This module's "stamped" filenames are rendered with Time::Piece's
strftimefunction. By default it uses
gmtimefor UTC timestamps, but this can be changed by passing
localtimeinto the constructor's
timezoneparameter (see the synopsis).
NOTE: Because of a caching optimisation, files should not be rotated more often than once per second.
If you pass in
current_symlinkto the constructor, it will create a symlink at your provided filename. This symlink will always link to the most recent log file. You can then use
tail -Fto monitor an application's logs with no interruptions even when the filename rolls over.
Constructs an object. An empty file will be created at this point.
Takes a message as an argument which will be stringified and appended to the current file.
Looking for functionality like log-levels and message time-stamping? Check out Log::Defer.
M. Jacob, <firstname.lastname@example.org>
This module was forked from Log::Dispatch::File::Rolling by Doug Hoyte.
Copyright (C) 2003, 2004, 2007, 2010, 2013 M. Jacob <email@example.com>, 2016 Doug Hoyte
Log::Dispatch::File::Stamped by Eric Cholet <firstname.lastname@example.org> Log::Dispatch::FileRotate by Mark Pfeiffer, <email@example.com>
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.