[logback-user] Delaying debug logs until an error occurs

Håvard Ottestad hmottestad at gmail.com
Sun Dec 31 11:30:31 CET 2017


Happy new year :D

I have a question that I’m having trouble formulating. 

My goal is to reduce the amount of logging in my application, but still log debug messages when there has been an error. 

I’m wondering if there is a way to have logback “save” debug messages and only log them if an error is logged at some point later on in the same transaction.

Eg. A spring web application. The user uploads a file, and at some point in the processing of the file an error occurs. Would be great now if the application would print out all debug messages associated with the file upload (including messages logged before the error), so that it would be possible to trace what happened leading up to the error. 

Having debug, info, warn and error on in production produces too many logs, which means we can’t keep them as long as we would like. So being able to trigger logging of previous debug messages on an error would give us a high level of detail in our logs when we need it the most.


More information about the logback-user mailing list