Application delay or hanging due to log4j

While profiling one of my multi-threaded applications, I found that some of my threads are in blocked state as some other thread is busy using the shared resource. The thread monitor was org.apache.log4j.spi.RootLogger which was blocking my threads. Finding the stack trace of the thread I found that the threads are using Log4j to write on the console using console appender and it is writing it serially therefore creating delay in my application.

Solution

The simple solution to this problem is to use AsyncAppender, using AsyncAppender with log4j usually is a good idea but the only problem is that AsynAppender buffer is not flushed completely on application exit.

It means that you get total discounts at the time of subscription. Dream – Host is an online hosting company that offers products like
domain registration, shared website hosting, Virtual Private Server (VPS), and public cloud services.
These connections and resource sharing can even be made across different operating systems such as Unix, Linux and Microsoft Windows.

Leave a Reply

About the Author

Syed Saulat Hussain Rizvi, a seasoned IT professional with extensive (14 years) of experience in software architecture, development and technical team leadership. Syed, has fourteen+ years of experience in analyzing, designing, implementing, deploying and supporting Business Intelligence and Enterprise Applications Software utilizing Java platform. He has successfully led complex projects with small and large teams, covering various aspects of software development, process and methodology. Extensive experience in Object-Oriented design and development, Java, J2EE, middleware and enterprise application architecture and implementation.