logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From paul womack <pwom...@papermule.co.uk>
Subject Multithreading issues - doAppend is synchronised?
Date Tue, 03 Nov 2009 12:13:07 GMT
I've been using Log4j succesfully for around 4 years now,
but I think I've recently hit a limitation.

I currently have multiple "leaf" loggers connected to multiple appenders,
using additivity=false.

The appenders are all RollingFileAppenders.

This works fine.

I also have an "ErrorAppender". This is also a RollingFileAppender,
but the layout is a good deal more detailed. It also has a threashold
of "ERROR".

Each "leaf" logger is also connected to the ErrorAppender.

The upshot of all this is that each logger sends debug()
info() and warn() logging to its (1:1) Appender (AKA log file),
but any errors are logged both to the loggers "own" appender,
and to the ERROR appender, with much more information.

This all works nicely.

The practical upshot is, when something goes wrong,
I look in the error log file first.

But I'm having a performance issue. All this is used
under a heavily multi-thread tomcat context.

Given that doAppend in AppenderSkeleton is synchronized
to the Appender instance, and that the threshold is checked
inside doAppend, it appears to me (I'm about to try to confirm)
that every single log() call will synchronise on
the ErrorAppender instance, even if the logging is at the lowest
level.

The practical upshot is that every single log call becomes
a sync() on a global object.

That can't be good.

Is this a known issue, or is my analysis all wet?

Frankly, I'd be happy to be wrong on this one.

   BugBear

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


Mime
View raw message