RSS Feed for This PostCurrent Article

Using Log4j AsyncAppender for Better Performance

I have described in my previous articles on the performance issue I faced for logging.

When I was monitoring the performance, I noticed that the bottleneck is always at the logging. I cannot avoid or reduce the logging as the information is required for troubleshooting purpose.

Finally I found a solution. Since I am using Apache Log4j, there is a feature called AsyncAppender that can be used to resolve the logging bottleneck.

As quoted from the documentation

The AsyncAppender lets users log events asynchronously.

The AsyncAppender will collect the events sent to it and then dispatch them to all the appenders that are attached to it. You can attach multiple appenders to an AsyncAppender.

The AsyncAppender uses a separate thread to serve the events in its buffer.

AsyncAppender uses separate thread for logging purpose. As such it is not blocking the execution thread.

However, AsynchAppender is not supported in a J2EE container. In this case, you can use JMSAppender, which is asynchronous also.


Trackback URL


Sorry, comments for this entry are closed at this time.