File::RotateLogs::Tiny - tiny File::RotateLogs
use File::RotateLogs::Tiny;
my $rotatelogs = File::RotateLogs::Tiny->new(
logfile => "/path/to/%Y%m%d.log",
);
$rotatelogs->print("logging!\n");
File::RotateLogs::Tiny is a limited File::RotateLogs.
File::RotateLogs is awesome, but I sometimes feel it is too feature-rich. That is, I don't want features of removing old logs and creating a symlink linking to the latest log.
I just want the feature of rotating log according to time.
my $rotatelogs = File::RotateLogs::Tiny->new(%option);
Constructor. %option
is
-
logfile
This is file name pattern. The format is POSIX's strftime. This is required.
-
open_layer
The open layer to open files. The default is
:unix
(non buffered). You may specify:unix:utf8
instead.
$rotatelogs->print("hello!\n");
Print to the log.
-
But, I want to remove old logs...
OK, let's use cron:
> crontab -l 1 5 * * * find /path/to/log/dir -type f -mtime +30 -delete
-
I want to compress old logs...
OK, let's use cron again:
> crontab -l 2 * * * * find /path/to/log/dir -type f -mtime +1 -exec gzip {}\;
Shoichi Kaji skaji@cpan.org
Copyright 2016 Shoichi Kaji skaji@cpan.org
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.