|
From: Mike S. <m...@pe...> - 2009-08-25 17:03:08
|
On Mon, 24 Aug 2009, Ronald Fischer wrote:
> Is there an easy way to limit the size of a log file? I'm not looking
> for a rollover solution, but for one, where a new file is created if
> the old one exceeds a certain size.
That's pretty much the case with Log::Dispatch::FileRotate, a given file
size, and a max value of 1. If somefile.log grows larger than 'size'
bytes, it'll move it over to somefile.log.1 and moves it over to
somefile.log. Alternatively, you can use an external rotator with
similar settings.
If you don't want to roll over, but truncate the logfile in this case
(although this seems weird, as you might end up with an almost-empty
logfile at times), you need to write your own appender as outlined in
http://search.cpan.org/dist/Log-Log4perl/lib/Log/Log4perl/FAQ.pm#How_can_I_write_my_own_appender?
> My idea is to intercept each call to Log4perl, test the size of the
> log file, and switch to a new log file if the old one got too big.
That's exactly what Log::Dispatch::FileRotate does if you call it with
a max value of 1.
-- Mike
Mike Schilli
m...@pe...
|