The AppenderSkeleton class defines the 'public synchronized void doAppend(LoggingEvent event)' method. Making this method non synchronized directly in AppenderSkeleton isn't safe as there are might be plenty of (custom 3rd party) subclasses that might take advantage of this synchronization. However, some widely used _concrete_ appenders that are defined inside the log4j library could be optimized. The AsyncAppender class seems to be the most often used appender in enterprise class systems. Making the doAppend() method non synchronized in this case makes a lot of sense as checking if level is lower than threshold is done in doAppend(). This change would improve log4j behavior in multi-threaded environments. AsyncAppender is anyway internally synchronized - it synchronizes on the buffer field. Attaching a subclass of AsyncAppender that removes the unnecessary 'synchronized' keyword.
Created attachment 26872 [details] A subclass of AsyncAppender that removes the unneeded synchronization