logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paul Smith <Paul.Sm...@lawlex.com.au>
Subject RE: AsyncAppender in log4j
Date Tue, 08 Apr 2003 22:40:30 GMT
> Logging of type 1: logging ====> log4j ===> 
> FileAppender(Which writes into local File).
> 
> Logging of type 2: logging ====> log4j ===>JMSAppender ===> 
> JMS Queue ===>JMS Adaptor ===> Helper Class which writes log 
> data onto a File or DB.

I think the reason that this requirement has never cropped up before is that
in an asynchronous-world, the App that is doing the logging is kinda relying
on guaranteed delivery of the LoggingEvent into the Appender's 'sink' (File,
JDBC, JMS Queue etc).  ie. If the Logging of the event fails, the App wants
to know about it quick smart, usually by an Exception thrown by the Log4j
logging method.

What becomes interesting is that some of the Appenders (JDBC, JMS) are not
exactly super-fast (compared with a simple File/Console)) at delivering the
Logging event to their 'sink' and Logging tends to slow the app down.  

An asychronous-model generally means a buffer of Events that get's streamed
to it's destination by another thread, and here's where you have a
limitation.  You can NEVER guarantee that an Asynchronous-based appender
will deliver ALL the logging events the app has requested it to.  Your app
could crash, leaving Logging events in the buffer, that get lost forever.
This may be ok in some situations, but it's a pretty large trade off.  I
would think in most situations the Logging Events in the buffer are exactly
the logging events you're REALLY interested in finding out what was going on
when the app crashes...

If it still interests people, my gut tells me this could be neatly packaged
into Log4j, but only with a reasonably large redesign of the Appender
hierarchy.  We'd need to have a Strategy object that each Appender delegates
the actual 'appending', with a call-back to a method that does the appender
specific appending.  The Simple-strategy just immediately calls that method
in the current Thread.  The Asynchronous-strategy buffers the event, and has
a background thread streaming the events into it's sink via the appender's
call-back.

Thoughts anyone?

cheers,

Paul Smith

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: log4j-dev-help@jakarta.apache.org


Mime
View raw message