[logback-user] Log4j LoggingEvent

Ceki Gulcu ceki at qos.ch
Wed May 13 13:52:52 CEST 2009

If reactivity is what you are looking for, I would suggest that you wrap 
SocketAppender in an appender which contains a queue (see AsyncAppender in 
log4j). Place logging events in a queue, and if the queue becomes full, drop new 

Code for computing location information and everything else can be done by 
invoking methods on LoggingEvent. You don't need to store the logger.

Holler if the above is not clear.

Greg Flex wrote:
> Hi Ceki,
> I (again) have some questions about log4j.
> (I guess Logback works the same way....)
> I was wondering if there's a way to save a "logger object" to a
> data structure like a queue or something before sending it to some appender.
> For example:
> The socket appender will cause the log4j client to lock/freeze if 
> there's no link to the server.
> I verified it and it does lock the client.
> I need to deal with this issue so I'd like to store "logger objects" (or 
> something)
> before they go to the socket or some other appender first.
> At the moment I have a wrapper around the log4j that when the debug 
> method is called
> I'm just calling the log4j debug method passing some args etc.
> so I have:   logger.debug("some stuff");
> The configuration file does the trick and outputs to the console (at the 
> moment) all the info:
> the class name, the method name, the line number etc.
> I'd like to save this info somehow to some object that I can store in a 
> queue or something.
> How do I retrieve this information programmatically? Is there a way?
> I know about LoggingEvent object, could I use it and pass the above 
> stated information
> to its constructor then store it in a queue?
> Logger gets me for free (like method name etc.)
> Any suggestion?
> Thanks a lot.
> Greg.
> ------------------------------------------------------------------------
> _______________________________________________
> Logback-user mailing list
> Logback-user at qos.ch
> http://qos.ch/mailman/listinfo/logback-user

Ceki Gülcü
Logback: The reliable, generic, fast and flexible logging framework for Java.

More information about the Logback-user mailing list