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

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

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

janolaveide@gmail.com
       
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 ?
Reply | Threaded
Open this post in threaded view
|

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

Donald McLean
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, [hidden email]
<[hidden email]> 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 ?
_______________________________________________
Logback-user mailing list
[hidden email]
http://mailman.qos.ch/mailman/listinfo/logback-user
Reply | Threaded
Open this post in threaded view
|

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

janolaveide@gmail.com
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.
Reply | Threaded
Open this post in threaded view
|

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

diroussel
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.