3 Replies Latest reply on Dec 13, 2011 2:42 PM by jamezp

    JDK 1.4+ logging instead of Log4J in JBoss7

    dmrrb

      Hi,

       

      How can I use JDK 1.4+ logging framework instead of Log4J in Jboss 7? My requirement is to redirect all my application logging messages to a log file defined by JDK1.4+ logging framework.

       

      I see the below post

      http://community.jboss.org/wiki/LoggingPlug-inJDKJavautillogging

      As it mentions it works only for jboss 4.x and 5.x.

       

      Is there another approach for this going forward with JBoss6+?

       

      Thanks,

      dmrrb

        • 1. Re: JDK 1.4+ logging instead of Log4J in JBoss7
          jamezp

          dmrrb,

          You can log with just about any logging framework and JBoss Logging will pick it up and output it. Currently we don't support any other configurations other than the logging configuration that is in the standalone.xml or the domain.xml. You could easily define a handler that outputs to a file via CLI, the web interface or by updating your configuration file.

           

          The following configuration added to the logging subsystem section in either your standalone.xml or the domain.xml will send log messages to the myFileLog.log file.

          <subsystem xmlns="urn:jboss:domain:logging:1.1">
              ....
              <file-handler name="myFileHandler">
                  <file relative-to="jboss.server.log.dir" path="myFileLog.log"/>
                  <append value="true" />
              </file-handler>
              ....
              <root-logger>
                  <level name="INFO" />
                  <handlers>
                      <handler name="CONSOLE" />
                      <handler name="FILE" />
                      <handler name="myFileHandler" />
                  </handlers>
              </root-logger>
          </subsystem>
          

           

          The above will log all messages to that file. If you want to use only log your messages to the file you can add a logger with the lowest level category that you use.

           

          <subsystem xmlns="urn:jboss:domain:logging:1.1">
              ....
              <file-handler name="myFileHandler">
                  <file relative-to="jboss.server.log.dir" path="myFileLog.log"/>
                  <append value="true" />
              </file-handler>
              ....
              <logger category="com.yourcompany">
                  <level name="INFO" />
                  <handlers>
                      <handler name="myFileHandler" />
                  </handlers>
              </logger>
          </subsystem>
          

           

           

          We are how ever working on a solution where you could just add a logging.properties file in your deployment that will automatically be detected and used to configure the logger. This is not upstream yet, but work is being done on it.

          1 of 1 people found this helpful
          • 2. Re: JDK 1.4+ logging instead of Log4J in JBoss7
            dmrrb

            Thanks James, I followed your approach to define a custom handler. But since the logging.properties file is not detected, that didn't work. So working on an alternative approach.

             

            I am having following questions now.

             

            1. What is the default logging framework used by JBoss 7? I see the below post and it hinted me it uses java util logging by default.

            http://community.jboss.org/thread/156915

             

            2. If I want to use Log4J instead how would I configure that?

             

            Many thanks,

            dmrrb

            • 3. Re: JDK 1.4+ logging instead of Log4J in JBoss7
              jamezp

              Hello dmrrb,

              Yes, the logging.properties file will not be detected. We are working on a solution for that, but it's not in the upstream at the moment. You will currently need to define the logging configuration in the standalone.xml or the domain.xml depending on which mode you're running in.

               

              1. We use JBoss Logging 3 in JBoss AS 7.

               

              2. You can use log4j for your own applications, but appenders and stuff like that will not currently work for messages not logged with log4j. Again we are working on a solution for this, but it's not complete yet.

               

              --

              James R. Perkins

              1 of 1 people found this helpful