[logback-user] Dumping a CyclicBuffer
mweeda
mweeda at 4idc.com
Thu Oct 16 01:03:21 CEST 2008
Hi,
Messages that pass the filters for RECENT, and are lower than the
DumpLevelThreshold, will *always* be logged to the buffer - there isn't an
event that starts accumulation.
Consider an application that is deployed to hundreds of users. A handful of
system crashes occur every day, and the support team cannot reproduce the
problem. While interviews or forms can be used to get some sense of what
users were doing when they crashed, that can be easier said then done,
especially if they aren't working at a desk.
To help resolve this kind of issue, we want a history of detailed activity
over a recent period whenever an error occurs. (When a previous error
occurred isn't of interest - we want the activity prior to the error that
has just occurred.) Sending detailed messages for hundreds of users to a
file over a period of hours (days even) is not so good in terms of disk
space, network traffic etc. This leads to the concept of a cyclic buffer
that is dumped when an error occurs.
You are right that the "default" settings might not gather an ideal period
of history for every investigation. As long as the code was written with the
ability to log sufficient details, it is easy to change logback.xml to
capture more helpful data. Two changes in particular would be to pass more
messages through the ThresholdFilter of RECENT (DEBUG or TRACE), and to
increase the size of its cyclic buffer.
A CyclicBufferDumpAppender could be attached to one or more class specific
loggers, instead of root. That isn't quite the same as having a trigger
event, but it could help capture relevant (hopefully) low level messages for
a longer time in less memory.
Mike
-----Original Message-----
From: logback-user-bounces at qos.ch [mailto:logback-user-bounces at qos.ch] On
Behalf Of Ceki Gulcu
Sent: Wednesday, October 15, 2008 5:18 PM
To: logback users list
Subject: Re: [logback-user] Dumping a CyclicBuffer
Hello,
Thank you for the attached files showing what you have come up with.
While the dump trigger is clear (a log statement of level error or
whatever the triggering threshold is), I don't see a "start
accumulation" trigger.
If I understand correctly, during the dump all events currently in the
cyclic buffer will be dumped. If the buffer size is large, then all
events up to the previous error will be dumped. If the buffer size is
small, too few events may be dumped. Hence my question about the
"start accumulation" trigger.
Cheers,
mweeda wrote:
> Thanks for your help, Ceki.
>
> The attached files will show you what I came up with. Synchronization
issues
> are avoided by having the same Appender add events to the CyclicBuffer and
> dump its contents. Ease of use is pretty high, since log.error(message)
> triggers a buffer dump. Configuration changes would allow log.X and higher
> to trigger a dump.
>
> --
Ceki Gülcü
Logback: The reliable, generic, fast and flexible logging framework for
Java.
http://logback.qos.ch
_______________________________________________
Logback-user mailing list
Logback-user at qos.ch
http://qos.ch/mailman/listinfo/logback-user
More information about the Logback-user
mailing list