4 Replies Latest reply on Dec 4, 2004 3:14 PM by ranvnrsoftware

    Log4J Example in the Wiki Not Working

    chipa

      I'm trying to configure JBoss so that it uses the Log4J configuration file in my WAR rather than the JBoss one in /conf. I found several posts in these forums where similar questions were asked. The answers usually pointed the user to a Wiki entry about logging:

      http://www.jboss.org/wiki/Wiki.jsp?page=Logging

      In the middle of that page, there is a section entitled "Using your own log4j.xml file - class loader scoping" which seems to contain the answer that I'm looking for - just create a jboss-web.xml file that looks like the one in the article and add it to your project's WEB-INF directory. Excellent.

      Unfortunately, it didn't seem to work. My log entries still appeared in the JBoss console rather than where I wanted them to. Things work fine under Tomcat, so I'm 95% sure my Log4J config is correct.

      As a test, I downloaded and installed the sample file (confusingly) called "Log4J.war" from the Wiki page and installed it. When I pulled up its "snoop.jsp" file, it's log entries also appeared on the JBoss console and not in "{server}/log/log4j-test.log".

      Does anyone know if there anything else that needs to be configured in order for the Wiki example to work? What version of JBoss is required? Can anyone else get "Log4J.war" to log to its file rather than to the console?

      TIA

        • 1. Re: Log4J Example in the Wiki Not Working
          chipa

          More digging revealed that the flag "loader-repository-config" may have been broken in 3.2.5 and before. According to this bug report, the problem has been fixed in 3.2.6:

          https://sourceforge.net/tracker/index.php?func=detail&aid=1017714&group_id=22866&atid=376685

          I'll download 3.2.6 tomorrow and report back here after running more tests.

          • 2. Re: Log4J Example in the Wiki Not Working
            chipa

            No luck. :-(

            A clean install of 3.2.6 exhibited the same behavior - the [Snoop] log messages go to the Console and not to the /logs/log4j-test.log file.

            Based on another post I found here, I also tried setting two attributes in /server/default/deploy/jbossweb-tomcat50.sar/jboss-service.xml to false:

            false
            false

            After restarting things, I got the same result.

            At this point, I'm out of ideas and so my original questions remain:

            Does anyone know if there anything else that needs to be configured in order for the Wiki example to work? What version of JBoss is required? Can anyone else get "Log4J.war" to log to its file rather than to the console?


            TIA


            • 3. Re: Log4J Example in the Wiki Not Working
              chipa

              Grrr... The two setting that didn't appear in my post above are:

              <attribute name="Java2ClassLoadingCompliance">false</attribute>
              <attribute name="UseJBossWebLoader">false</attribute>


              Sorry about that...

              • 4. Re: Log4J Example in the Wiki Not Working
                ranvnrsoftware

                Chipa:

                This may not be a great help, but I followed the instructions in the wiki and it worked fine for me.

                Are you using log4j.properties? If so, you need to rename JBoss' log4j.xml file so log4j doesn't pick that up in preference to your log4j.properties. The wiki mentions how to do that. (Btw, I am using log4j.properties.)

                Hope this helps.

                Bob