3 Replies Latest reply on Aug 13, 2010 3:49 AM by jaikiran pai

    How to create application specify logging in JBoss AS 6 M4

    Mohd Hafifi Hafidz Md Zuki Newbie

      Hi,

       

      I have search everywhere on how to set up application specify logging in JBoss AS 6 M4.

      As far as i know, starting from JBoss 6 AS 6 M3, JBoss use jboss-logging.xml for

      defining log4j.

       

      Also in jbossas\docs\examples\jmx\logging-monitor\lib\logging-monitor.jar, when i read it documentation,

      it asked me to copy example in jbossas\docs\examples\jmx\logging-monitor\deploy\.

      But there is nothing in that folder.

       

      1. How do i do this in M4 using my application own logging.xml

       

      Help from you guys whould be much appreciated.

       

       

      Thanks

        • 1. Re: How to create application specify logging in JBoss AS 6 M4
          jaikiran pai Master

          Hmm, going by the number of questions similar to this, for AS-6, looks like we'll need a wiki for this soon.

          Mohd Hafifi Hafidz Md Zuki wrote:

           

          Hi,

           

          I have search everywhere on how to set up application specify logging in JBoss AS 6 M4.

          As far as i know, starting from JBoss 6 AS 6 M3, JBoss use jboss-logging.xml for

          defining log4j.

           

          jboss-logging.xml is the configuration file specific to jboss-logging project. It's a different matter that you can configure log4j-appender in there, but I personally wouldn't recommend it. One of the reason being - it's a JBoss specific file so those configs wont work if you are to use the same app in some other container.

           

          Mohd Hafifi Hafidz Md Zuki wrote:

           


          Also in jbossas\docs\examples\jmx\logging-monitor\lib\logging-monitor.jar, when i read it documentation,

          it asked me to copy example in jbossas\docs\examples\jmx\logging-monitor\deploy\.

          But there is nothing in that folder.

          Hmm, I didn't even know there was such an example. It's for sure outdated. So ignore that.

           

          Mohd Hafifi Hafidz Md Zuki wrote:


           

          1. How do i do this in M4 using my application own logging.xml

           

          Help from you guys whould be much appreciated.

           

           

           

           

          Are you using log4j in your application? If yes, then just package that log4j.xml within your application such that it's available in the classpath of the app. For example, if your application is a .war file, then package it in .war/WEB-INF/classes. That should be enough. 

           

          If you have any further questions, feel free to ask.

          • 2. Re: How to create application specify logging in JBoss AS 6 M4
            Mohd Hafifi Hafidz Md Zuki Newbie

            Thanks for the reply..

             

            If i were to use log4j.xml, do i need to include log4j jar also in my library?

            Currently i'm using log4j-1.2.16.jar. If i were to use my own application log4j jar

            if im not mistaken i need to tell jboss in jboss-web.xml to overwrite this.

            I have tried this. But it seems like it can't locate my log4j.xml

             

            2010-08-12 12:15:25,296 ERROR [STDERR] (http-127.0.0.1-8080-3) log4j:ERROR Could not read configuration file [config/log4j.xml].
            2010-08-12 12:15:25,296 ERROR [STDERR] (http-127.0.0.1-8080-3) java.io.FileNotFoundException: config\log4j.xml (The system cannot find the path specified)
            2010-08-12 12:15:25,296 ERROR [STDERR] (http-127.0.0.1-8080-3)     at java.io.FileInputStream.open(Native Method)
            2010-08-12 12:15:25,296 ERROR [STDERR] (http-127.0.0.1-8080-3)     at java.io.FileInputStream.<init>(FileInputStream.java:106)
            2010-08-12 12:15:25,296 ERROR [STDERR] (http-127.0.0.1-8080-3)     at java.io.FileInputStream.<init>(FileInputStream.java:66)

             

            Do i need to define my class path in eclipse anywhere?

             

            Anyway, is it possible not to include log4j jar into my project, instead just use jboss log4j.

             

            Thanks

            • 3. Re: How to create application specify logging in JBoss AS 6 M4
              jaikiran pai Master

              Mohd Hafifi Hafidz Md Zuki wrote:

               

              Thanks for the reply..

               

              If i were to use log4j.xml, do i need to include log4j jar also in my library?

              Currently i'm using log4j-1.2.16.jar. If i were to use my own application log4j jar

              if im not mistaken i need to tell jboss in jboss-web.xml to overwrite this.

              I have tried this. But it seems like it can't locate my log4j.xml

               

              2010-08-12 12:15:25,296 ERROR [STDERR] (http-127.0.0.1-8080-3) log4j:ERROR Could not read configuration file [config/log4j.xml].
              2010-08-12 12:15:25,296 ERROR [STDERR] (http-127.0.0.1-8080-3) java.io.FileNotFoundException: config\log4j.xml (The system cannot find the path specified)
              2010-08-12 12:15:25,296 ERROR [STDERR] (http-127.0.0.1-8080-3)     at java.io.FileInputStream.open(Native Method)
              2010-08-12 12:15:25,296 ERROR [STDERR] (http-127.0.0.1-8080-3)     at java.io.FileInputStream.<init>(FileInputStream.java:106)
              2010-08-12 12:15:25,296 ERROR [STDERR] (http-127.0.0.1-8080-3)     at java.io.FileInputStream.<init>(FileInputStream.java:66)

               

              It really depends on how you are initializing the log4j configuration. Looking at that code, it appears that you are programatically booting log4j. In that case, I don't think you will require the log4j jar to be packaged in your .war. But I would still recommend that you package it, after all the one shipped in JBoss AS might not be the version you want to use.

               

              As for that exception, it looks like you are using java.io.Filexxx to get hold of the conf/log4j.xml. That won't work in a server runtime, because conf/log4j.xml is not the absolute path. Please post the relevant code where you are loading this configuration and also post the exact location in the .war where this file is located.