Smarter log handling, the case for opportunistic logging
zeroturnaround.com
zeroturnaround.com
There's even an implementation built right into log4j, 13 years ago, the SMTPAppender: http://svn.apache.org/viewvc/logging/log4j/trunk/src/main/ja...
How is that better?
For example, keep a rolling window of two or three hours of trace logging in memory. If the number of errors in that window passes a threshold, write the full trace out to disk, otherwise just write the info logging.
You save on disk space while having detailed logging around errors.
We have prototypes of this in our software (but not production code yet) with buffers that default to 50MB. That gives a nice amount of debug info in the run up to any errors.
Whenever the buffer is dumped out you simply set the begin/end pointers of the cyclic buffer to be the same so that subsequent errors don't write out an entire copy of the buffer again, only the new log messages since the previous error.