3 Replies Latest reply on Oct 12, 2015 8:53 AM by Nathan Clark

    Log4j not working with AS7.4 bundled with JDS 8.1.0.GA

    Nathan Clark Newbie

      I've read some statements on here suggesting that JBoss AS versions after 7.1 auto-detect and configure log4j logging, smoothing out some issues with previous releases. My understanding is that to get this behavior, you remove log4j.jar from the deployment (so that you get the container-supplied implementation of log4j), and leave your log4j.xml in the classpath where it always was. During application deployment all application archives are scanned for log4j (or slf4j or JUL) configurations, and if those are found, their configuration info is used seamlessly. Of course, in this scenario you would not exclude the container logging module, and you would not touch the "org.jboss.as.logging.per-deployment" flag.


      This is not working for me. My log4j.xml defines System.out and System.err appenders, as well as a rolling file appender. The file doesn't get created, and none of the log4j output appears in the console. No errors related to the application logging config appear in the JBoss server log. Are my assumptions correct? What else could be wrong?

      This application has been in production for 8 years on WAS, and the logging of course works there. A migration to JBoss AS 5 was begun, never completed (I don't know if logging ever worked there.) The JBoss AS 5 migration was then re-targetted for AS 7 in mid-stream. That's the effort I'm now working to complete.

      Perhaps I should stress that I'm doing this in the JBoss Developer Studio using the built-in server. Oddly, I have to keep the log4j jar present in the workspace (because I can't seem to be able to import it from the EAP), but avoid it getting into the Deployment Assemblies. (A secondary issue I'd like to resolve: is there some JBoss library I can pull into the workspace to satisfy this Eclipse-level dependency?)

      I should also mention that converting all the logging code to the new JBoss-proprietary loggers is not an option at this time.

      One more thing: the log4j version previously used was 1.2.14, so the log4j.xml structure presumably conforms to that.

        • 1. Re: Log4j not working with AS7.4 bundled with JDS 8.1.0.GA
          Tomaž Cerar Master

          what is the exact version of JBoss you are using now?


          In title you mention JBoss EAP 6.3 (AS7.4) than you talk about 7.1 and 5 behavior.


          As some stuff you are asking about changed after 7.1 in EAP6.1 and 6.2, so exact version would help answer the question.

          • 2. Re: Log4j not working with AS7.4 bundled with JDS 8.1.0.GA
            James Perkins Master

            You can use log4j with or without a configuration file. If you don't include a configuration file then the logging subsystem is used to configure logging.


            If you do want to use a log4j.xml that works too. Where is the file located in your deployment? It should be in the META-INF directory or for a WAR it could also be in the WEB-INF/classes directory.



            James R. Perkins

            • 3. Re: Log4j not working with AS7.4 bundled with JDS 8.1.0.GA
              Nathan Clark Newbie

              Log4j started working immediately after these 2 changes:

              1. updated Spring from 2.0.6 to 3.2.9
              2. removed a log4j jar from the Eclipse workspace that I was not deploying in server jars, just keeping around to satisfy local Java Build Path dependencies (the second issue I mentioned above). I had also checked the EARs, WARs and JARs to make sure it wasn't getting into the deployment - and didn't find it. I was able to get this jar out of the build path by creating a User Library that includes log4j-jboss-logmanager-1.0.1.Final.redhat-2.jar found in the local server's modules folders.

              It would be nice to understand this in more depth, but I have to move on to other build problems now. Thanks for your replies!