File::RotateLogs - File logger supports log rotation
use File::RotateLogs; use Plack::Builder; my $rotatelogs = File::RotateLogs->new( logfile => '/path/to/access_log.%Y%m%d%H%M', linkname => '/path/to/access_log', rotationtime => 3600, maxage => 86400, #1day ); builder { enable 'AccessLog', logger => sub { $rotatelogs->print(@_) }; $app; };
File::RotateLogs is utility for file logger. Supports logfile rotation and makes symlink to newest logfile.
This is file name pattern. It is the pattern for filename. The format is POSIX::strftime(), see also POSIX.
Filename to symlink to newest logfile. default: none
default: 86400 (1day)
Maximum age of files (based on mtime), in seconds. After the age is surpassed, files older than this age will be deleted. Optional. Default is undefined, which means unlimited. old files are removed at a background unlink worker.
Sleep seconds before remove old log files. default: 3 If sleep_before_remove == 0, files are removed within plack processes. Does not fork background unlink worker.
The number of seconds offset form UTC. default: 0 If offset is omitted or set zero, UTC is used. When rotationtime is 24h and offset is 0, log is going to be rotated at 0 O'clock (UTC). For example, to use local timezone in the zone UTC +9 (Asia/Tokyo), set 32400 (9*60*60).
Masahiro Nagano <kazeburo {at} gmail.com>
File::Stamped, Log::Dispatch::Dir
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install File::RotateLogs, copy and paste the appropriate command in to your terminal.
cpanm
cpanm File::RotateLogs
CPAN shell
perl -MCPAN -e shell install File::RotateLogs
For more information on module installation, please visit the detailed CPAN module installation guide.