0 Replies Latest reply on Jul 17, 2014 1:05 PM by Robert Heim

    How to configure JBoss 5.1.0.GA to use Log4j2

    Robert Heim Newbie

      Recently we have run into what appears to be lock contention with the default log4j package (1.2.14) that ships with JBoss 5.1.0.GA.

       

      Our application has been running fine at various locations with the following basic configuration - JBoss 5.1.0.GA as a standalone configuration using JDK 1.6.0_45 (x64).  We are using the default log4j configuration provided by JBoss.  We modified the CONF\jboss-log4j.xml file to include our own application log files and this is fine unless we are at high load.

       

      When we have a large number of concurrent requests we have detected blocking caused by the log4j libraries trying to look up the loggers in the Hierarchy class.

       

      Thread: http-0.0.0.0-80-1 : priority:5, demon:true, threadId:121, threadState:BLOCKED

      - waiting on <0xfe7b07> (a java.util.Hashtable)
      org.apache.log4j.Hierarchy.getLogger(Hierarchy.java:267)
      org.apache.log4j.Hierarchy.getLogger(Hierarchy.java:242)
      org.apache.log4j.LogManager.getLogger(LogManager.java:188)
      org.apache.log4j.Logger.getLogger(Logger.java:104)
      org.jboss.logbridge.LogBridgeHandler.publish(LogBridgeHandler.java:71)
      java.util.logging.Logger.log(Logger.java:481)
      org.jboss.logmanager.LoggerInstance.log(LoggerInstance.java:185)
      java.util.logging.Logger.doLog(Logger.java:503)
      java.util.logging.Logger.logp(Logger.java:646)
      java.util.logging.Logger.exiting(Logger.java:961)

      All signs point to a synchronized Hashtable in the Hierarchy class in getLogger.  Looking at the source code, it doesn't appear like this problem is fixed in the latest log4j 1.2 implementation (1.2.17).

       

      Based on what I found, it looks like log4j2 has resolved this particular issue so I'd like to try and reconfigure JBoss 5.1.0 to use log4j2 across the board.

       

      I modified our application so that is should work with log4j2 now (modified imports and changed calls from Logger.getLogger to LogManager.getLogger).

       

      At this point, I'm trying to figure out how to modify JBoss to use log4j2.  Here is what I have tried.

      1.  Copied the just released version of log4j2 jars (log4j-1.2-api.2.0.jar, log4j-api.2.0.jar, log4j-core-2.0.jar, log4j-web-2.0.jar) to the <Root>\lib directory.

      2.  Removed the following jars from the <Root>/lib directory

        jboss-logging-jdk.jar

        jboss-logging-log4j.jar

        jboss-logging-spi.jar

        jboss-manager.jar

      3.  Added the following jars to <Root>/lib  - (it was my understanding these jars were needed to support log4j2)

         jboss-logging-2.3.0.Beta1.jar

         jboss-logmanager-1.2.2.GA.jar

      3.  Created a new jboss-log4j.xml file (see attached)

       

       

      When I attempt to start up the sever I get class not found errors on the jboss.LogManager.  If I manually add that to the classpath it get other deployment errors.
      For those folks who are using log4j2, can you share what configuration changes you needed to make to get this to work?