Application delay or hanging due to log4j

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.

2 Responses to “Application delay or hanging due to log4j”

  1. If you desire to improve your knowledge simply keep visiting
    this web site and be updated with the newest news posted here.

  2. 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

Spam Protection by WP-SpamFree

Einfobuzz Site Map