Is grouped (deferred) log statements from same threads possible using logback?

I have read about the Mapped Diagnostic Context, and although useful, the log statements from different threads still appear interspersed in the output. What I would like is to have all log statements from a thread outout consecutively when that thread is done (and I know what and when "done" is) For example : Thread A starts at time T-Astart, performs logging at various points, and is done at T-Adone. Before A is done, at time T-Bstart (T-Adone < T-Bstart < T-Adone) another thread B starts processing, does the same kind of logging and finishes at T-Bdone. Now, I would like all logging statements from thread A to appear before the logging statements from Thread B, and not interspersed as the MDC examples I have seen. Is this kind of deferred, grouped logging possible with logback ? -- View this message in context: http://logback.10977.n7.nabble.com/Is-grouped-deferred-log-statements-from-s... Sent from the Users mailing list archive at Nabble.com.

This is a problem that I run into all the time. I'm thinking that it would be easier to handle the problem with tools that read and parse the log file after the fact - or use a database appender. The number of debug entries on a particular thread is unconstrained and this could cause logback to suffer from low memory or out of memory problems trying to pre-sort them. I've actually been working on a tool for this and have made some progress. Donald On Thu, Mar 7, 2013 at 1:21 PM, janolaveide@gmail.com <janolaveide@gmail.com> wrote:
I have read about the Mapped Diagnostic Context, and although useful, the log statements from different threads still appear interspersed in the output.
What I would like is to have all log statements from a thread outout consecutively when that thread is done (and I know what and when "done" is)
For example :
Thread A starts at time T-Astart, performs logging at various points, and is done at T-Adone.
Before A is done, at time T-Bstart (T-Adone < T-Bstart < T-Adone) another thread B starts processing, does the same kind of logging and finishes at T-Bdone.
Now, I would like all logging statements from thread A to appear before the logging statements from Thread B, and not interspersed as the MDC examples I have seen. Is this kind of deferred, grouped logging possible with logback ?

Interesting, my threads are very short lived (basically handling a single operation), so I am not that concerned about memory usage. In fact, in fact, my grouped entries do not even have to be chronological. If entries from thread B appear earlier than those from A in my example, that's OK as long as all B's are written before all As. Since I am very new to lockback I am not sure about the best way to proceed, but some stateful Encoder is what I am currently thinking. -- View this message in context: http://logback.10977.n7.nabble.com/Is-grouped-deferred-log-statements-from-s... Sent from the Users mailing list archive at Nabble.com.

This requirement could be met if this enhancement was implemented: http://jira.qos.ch/browse/LOGBACK-515 You'd want to have pluggable triggers, so you could use an MDC value as a trigger instead of the logging level. -- View this message in context: http://logback.10977.n7.nabble.com/Is-grouped-deferred-log-statements-from-s... Sent from the Users mailing list archive at Nabble.com.
participants (3)
-
diroussel
-
Donald McLean
-
janolaveide@gmail.com