Thanks a lot Curt,
it was my suspicion.

cheers,
Ste

On 11/03/2010 6.00, Curt Arnold wrote:
On Mar 10, 2010, at 10:37 AM, Stefano Nichele wrote:

Hi all,
looking for perfomance issue in my server application, I found that 
AppenderSkeleton.doAppend method is synchronized.
I google a bit and I have found some messages but not a clear anwser to my doubt: why 
that method is synchronized ? it seems that just check the threshold, the filter and that 
"append" the event but in this way is serializing all log calls. I'm logging 
events on the db and also using AsyncAppender + my own appender I'm not able to obtain 
good performance since just one thread at time can append (insert) an event and the 
AsyncAppender queue grows pretty quick.

For sure i'm missing something...could you help me to understand the root 
reason for having it synchronized ? I'm thinking to have my owm implementation 
of AppenderSkeleton removing synchronization but I'm not sure if there are 
drawbacks that im not taking in consideration.

Thanks a lot in advance
ste


log4j 1.2 was designed a long time ago and relies on that big lock to provide 
thread safety.  Other classes in log4j (layouts, appenders and the like) were 
designed assuming that they would be externally synchronized by that lock and 
likely not safe if that lock is bypassed.

You could either implement the Appender interface or extend AppenderSkeleton 
but override doAppend (copying and pasting the implementation but without the 
synchronized modifier, but all appenders, layouts, etc used must be able to 
operate safely without that lock.

Addressing this issue is one of the core design goals for log4j 2.0 
(http://issues.apache.org/jira/browse/LOG4J2-3)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]




--
Stefano Nichele

Funambol Chief Architect
Funambol :: Open Source Mobile Cloud Sync and Push Email



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to