You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4net-user@logging.apache.org by John Gu <jo...@gmail.com> on 2009/08/19 07:52:59 UTC

asynchronous logging using log4net

Hello,
Looking through the archives, I see attempts in the past to add asynchronous
logging to log4net, but am not sure if the efforts have gone anywhere.  I
would appreciate some feedback on how to accomplish what is conceptually a
pretty simple task.  I would like to do the following:

1) have a logging thread solely responsible for the actual I/O component of
logging (in this case, I'm only concerned with logging to console and/or to
file).  the logging thread would process logging events from some sort of
queue
2) a way of having multiple producers append logging events to the logging
queue from various "producer threads"

One additional consideration: rendering - I want to be able to control when
rendering occurs.  Having rendering in the producer threads guarantees that
the data rendered is what you actually want to log - assuming you're passing
in mutable objects to the logging statements that might change between the
time the logging call is made vs. when the logging message is actually
rendered.  Alternatively, if you are only passing in non-mutable objects or
implicitly make the guarantee that nothing will change, rendering the
logging message in the logging thread is more efficient.

Based on what I want to do and from the googling I've done, I don't believe
that writing a custom Appender will do this.  Instead, it seems like the way
to go is to implement a custom ILog object the proxies Debug / Log / Warn
calls by adding the arguments to a queue.  However, this is just a guess.
 Perhaps a better solution already exists.  Any help / feedback here would
be greatly appreciated.  Thanks!

Best,
John

P.S. I accidentally sent this message to the dev thread as well.  So my
apologies if you see this message there.  I didn't mean to spam.