On Tue, 28 Apr 2009, Andreas Altergott wrote:

> is there a possibility to increase the log level when an error occurs
> and print passed logs with the increased log level?

The Buffer appender implements this:

http://search.cpan.org/~mschilli/Log-Log4perl/lib/Log/Log4perl/Appender/Buffer.pm

Also, the FAQ has an entry that describes something similar:

     
http://search.cpan.org/dist/Log-Log4perl/lib/Log/Log4perl/FAQ.pm#How_can_I_bundle_several_log_messages_into_one?

So, if you modify the "TallyAppender" described there, you could make it
ring-buffer a number of messages, and trigger a flush when
a higher-level error occurs.

Another way of accomplishing this would be logging to two different log
files, one with a high log level (e.g. ERROR) and the other one with
a log level that provides you with the level of detail desired (e.g.
DEBUG). With a log rotator, you can limit the amount of disk space used
by the detailed log, and implement ring-buffer-like functionality this
way.

Hope that helps!

-- Mike

Mike Schilli
m...@perlmeister.com

>
> This would be very handy if you have a server application running, with
> a very low log level, to produce as less logging data as necessary.
>
> But once an error occurs this data is not sufficient.  It would be nice
> to log additionally to the stack backtrace all the passed logs with a
> higher log level.
>
> I know that the log output would be buffered.  This would mean that even
> though a logging event occured there'll be no output immediately.
>
> There might even be security concerns because the logging data might get
> lost, if the server crashes, before the buffer has been flushed.
>
> But nevertheless this is probably a good feature for server applications
> where real time logging is not the top priority.
>
>
> Regards,
> Andreas
>

------------------------------------------------------------------------------
Register Now & Save for Velocity, the Web Performance & Operations 
Conference from O'Reilly Media. Velocity features a full day of 
expert-led, hands-on workshops and two days of sessions from industry 
leaders in dedicated Performance & Operations tracks. Use code vel09scf 
and Save an extra 15% before 5/3. http://p.sf.net/sfu/velocityconf
_______________________________________________
log4perl-devel mailing list
log4perl-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/log4perl-devel

Reply via email to