Re: [log4perl-devel] Limiting file size in log4perl

2009-08-26 Thread Ronald Fischer
On Tue, 25 Aug 2009 09:39 -0700, Mike Schilli m...@perlmeister.com
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. 

Thanks a lot! The perldoc says that FileRotate provides a simple object 
for logging to files under the Log::Dispatch::* system, so I'm
surprised
that it will also work with Log::Log4perl, but I'll give it a try.

Ronald
-- 
Ronald Fischer rona...@eml.cc
+  If a packet hits a pocket on a socket on a port, 
+  and the bus is interrupted and the interrupt's not caught,
+  then the socket packet pocket has an error to report.
+   (cited after Peter van der Linden)


--
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
___
log4perl-devel mailing list
log4perl-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/log4perl-devel


Re: [log4perl-devel] Limiting file size in log4perl

2009-08-26 Thread Mike Schilli
On Wed, 26 Aug 2009, Ronald Fischer wrote:

 Thanks a lot! The perldoc says that FileRotate provides a simple
 object for logging to files under the Log::Dispatch::* system, so I'm
 surprised that it will also work with Log::Log4perl, but I'll give it
 a try.

Yep, Log4perl fully supports the Log::Dispatch appenders:

 
http://search.cpan.org/dist/Log-Log4perl/lib/Log/Log4perl.pm#Additional_Appenders_via_Log::Dispatch

If there's an equivalent in Log4perl (like for a file appender), using
the native appenders is recommended because they provide additional
functionality.

-- Mike

Mike Schilli
m...@perlmeister.com

--
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
___
log4perl-devel mailing list
log4perl-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/log4perl-devel


Re: [log4perl-devel] Limiting file size in log4perl

2009-08-25 Thread Mike Schilli
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...@perlmeister.com

--
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
___
log4perl-devel mailing list
log4perl-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/log4perl-devel