title: Log4j Multithreading in Solaris
body: <p>I have a multithreaded application and im using log4j for the logging. When i test my application on my windows 7/intel laptop, it works just fine. But when i deploy the same application to the production server(solaris/sparc), it works for 10 minutes then starts to slow down(very slow). I used profiler to see the threads state. There were a lot of threads blocked because of the log4j operations in the thread dump. Im also using async appender but coulnd't manage to get any successful result. Any guess?</p>
  
  <p>Here are some dump:</p>
  
  <pre><code>"pool-7-thread-105" - Thread t@22939
     java.lang.Thread.State: BLOCKED
      at org.apache.log4j.Category.callAppenders(Category.java:204)
      - waiting to lock &lt;794f2dae&gt; (a org.apache.log4j.spi.RootLogger) owned by "pool-7-thread-112" t@22946
      at org.apache.log4j.Category.forcedLog(Category.java:391)
      at org.apache.log4j.Category.info(Category.java:666)
  
  "pool-7-thread-112" - Thread t@22946
     java.lang.Thread.State: RUNNABLE
      at java.io.FileOutputStream.writeBytes(Native Method)
      at java.io.FileOutputStream.write(Unknown Source)
      at java.io.BufferedOutputStream.flushBuffer(Unknown Source)
      at java.io.BufferedOutputStream.flush(Unknown Source)
      - locked &lt;5fcbc329&gt; (a java.io.BufferedOutputStream)
      at java.io.PrintStream.write(Unknown Source)
      - locked &lt;19e9d0c5&gt; (a java.io.PrintStream)
      at sun.nio.cs.StreamEncoder.writeBytes(Unknown Source)
      at sun.nio.cs.StreamEncoder.implFlushBuffer(Unknown Source)
      at sun.nio.cs.StreamEncoder.implFlush(Unknown Source)
      at sun.nio.cs.StreamEncoder.flush(Unknown Source)
      - locked &lt;3680c465&gt; (a java.io.OutputStreamWriter)
      at java.io.OutputStreamWriter.flush(Unknown Source)
      at org.apache.log4j.helpers.QuietWriter.flush(QuietWriter.java:59)
      at org.apache.log4j.WriterAppender.subAppend(WriterAppender.java:324)
      at org.apache.log4j.WriterAppender.append(WriterAppender.java:162)
      at org.apache.log4j.AppenderSkeleton.doAppend(AppenderSkeleton.java:251)
      - locked &lt;3fddded7&gt; (a org.apache.log4j.ConsoleAppender)
      at org.apache.log4j.helpers.AppenderAttachableImpl.appendLoopOnAppenders(AppenderAttachableImpl.java:66)
      at org.apache.log4j.Category.callAppenders(Category.java:206)
      - locked &lt;794f2dae&gt; (a org.apache.log4j.spi.RootLogger)
      at org.apache.log4j.Category.forcedLog(Category.java:391)
      at org.apache.log4j.Category.info(Category.java:666)
  </code></pre>
  
  <p>Also log4j.xml - version 1.2.17</p>
  
  <p>
  
  </p>
  
  <pre><code>&lt;appender name="scripts" class="org.apache.log4j.DailyRollingFileAppender"&gt;
      &lt;param name="threshold" value="INFO"/&gt;
      &lt;param name="file" value="log/script.log"/&gt;
      &lt;param name="DatePattern" value="'.'yyyy-MM-dd"/&gt;
      &lt;layout class="org.apache.log4j.EnhancedPatternLayout"&gt;
          &lt;param name="ConversionPattern"
                 value="%-6p[%-d{ISO8601}] [%t] %m (%F:%L) %n"/&gt;
      &lt;/layout&gt;
  &lt;/appender&gt;
  
  &lt;appender name="stdout" class="org.apache.log4j.ConsoleAppender"&gt;
      &lt;param name="threshold" value="INFO"/&gt;
      &lt;layout class="org.apache.log4j.PatternLayout"&gt;
          &lt;param name="ConversionPattern" value="%-6p[%-d{ISO8601}] [%t] %m (%F:%L) %n"/&gt;
      &lt;/layout&gt;
  &lt;/appender&gt;
  
  &lt;appender name="ASYNC" class="org.apache.log4j.AsyncAppender"&gt;
      &lt;param name="BufferSize" value="5000"/&gt;
      &lt;appender-ref ref="scripts"/&gt;
  &lt;/appender&gt;
  
  &lt;root&gt;
      &lt;priority value="debug"/&gt;
      &lt;appender-ref ref="stdout"/&gt;
      &lt;appender-ref ref="ASYNC"/&gt;
  &lt;/root&gt;
  </code></pre>
  
  <p></p>