Hi Michiel,

The benefit of the AsyncAppender is not that logging
runs faster (ie log messages get written to disk faster),
but that code which *calls* log methods runs faster,
because it does not wait for the logged message to
be written.

In order to prove this, what you need is a very slow Appender
class (like the JMSAppender, or a JDBCAppender where there
is contention for the table).

You also need the "main" code to be doing some blocking operations
so that the logging thread has some time to run in - or be running on
a multi-processor machine, where logging can truly be happening in
parallel. I think that this situation will actually be fairly common in 
real code - most applications do I/O from time to time. The problem
is really to come up with a simple test case to demonstrate this.

I suspect that the FileAppender writing to a local file (esp. on a
good OS with file cacheing) has so little delay that the 
AsyncAppender's overhead is going to be more than the gains.
As mentioned above, the JMSAppender or JDBCAppender are
more likely to benefit from AsyncAppender, though you might
see some gains if the file is actually NFS-mounted or something
like that which increases the access time significantly...

How about creating an appender (subclass FileAppender) which 
does a sleep of 1 second before writing each message? Trying
this appender with your test harness should make the difference
more obvious...of course, you need to sleep in the main loop for
at least as long as the time the appender takes to write the
log event, or the buffer will grow...

Regards,

Simon

> -----Original Message-----
> From: Michiel Meeuwissen [SMTP:[EMAIL PROTECTED]]
> Sent: Monday, February 12, 2001 11:00 AM
> To:   LOG4J Users Mailing List
> Subject:      AsyncAppender in linux
> 
> 
> I did a little research if using the AsyncAppender would make
> sense. So, I made a little program with delays in it etc, as is
> suggested in the Logging javadoc of log4j. I do find no improvements
> tough in the performance, when using AsyncAppender. The thing is,
> that even without AsyncAppender logging gets faster. 
> 
> So, before that I'm going to do everything all over again, to check
> the results, I have a question.
> 
> I'm using linux. Could that have anything to do with it? I think I've
> heard that linux buffers in- and output by itself? If that it true,
> the whole AsyncAppender in linux (and other Unixes?) would be rather
> senseless, isn't it?
> 
> greetings,
> 
>  Michiel
> 
> -- 
> Michiel Meeuwissen - NOS internet 
> Mediacentrum kamer 203 - tel. +31 (0)35 6773065
> http://www.mmbase.org  
> http://www.purl.org/NET/mihxil/
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to