logging-log4net-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Nicko Cadell" <ni...@neoworks.com>
Subject RE: Log4Net Implentation Details - Is it Synchronous or Asynchronous?
Date Fri, 19 Aug 2005 20:33:13 GMT
Log4net delivers log events to the appenders synchronously. How they are
processed from there is dependant on the appender's implementation.

The FileAppender is synchronous and writes one log event at a time. Also
because files do not support multithreaded access the FileAppender uses
a lock to serialise access from multiple threads. This may incur
additional overhead for applications that use many threads and output a
high volume of log messages.

Because log4net is primarily an application logging library it, by
default, is setup to flush eagerly to disk in case that application
terminates unexpectedly. It is important to ensure that all possible log
events have been output.

The time taken for a log.XXX method is not known simply because the
appender's are pluggable. It is quite possible to configure log4net to
use a 'slow' appender. log4net cannot guarantee that logging will be
completed in a timely manner (or even that it will complete). If you
can't afford to wait for log4net, however it has been configured, to
complete a logging call, then you must call it asynchronously. I would
suggest using a shared buffer with a single worker thread that logs the
buffer once it reaches a certain size.

Cheers,
Nicko


> -----Original Message-----
> From: Shireesh Thanneru [mailto:thanneru@yahoo.com] 
> Sent: 19 August 2005 20:48
> To: log4net-user@logging.apache.org
> Subject: Log4Net Implentation Details - Is it Synchronous or 
> Asynchronous?
> 
> Forgive me if this questions was already asked before. I did 
> read the archives, but couldn't find a similar entry. My 
> question is does Log4Net does logging synchronously 
> (basically, for example, log.Info(msg) does not return until 
> msg is physically written to the log file/sink) or 
> asynchronously (log.info(msg) will immediately return and the 
> actual logging happens later asynchronously).
>  
> If it is synchronous, I would like to know how log4net 
> managed to be so fast (is there any other interal 
> buffering/queueing going on or is it a pure blocking call)? 
> We are implementing an Instrumentation extension (that logs 
> how much time each method is taking to a performance log file 
> and/or a performance counter) to log4net and are debating 
> whether to do it asynchonously/synchonoulsy or to use 
> multithreading. Your recommendation is greatly appreciated.
>  
> Thanks for your help.
>  
> Regards,
>  
> Shireesh Thanneru
> 

Mime
View raw message