8 Replies Latest reply on Apr 1, 2013 1:15 PM by shaam shaam

    unable to use application level java.util.logging in JBoss AS 7.1.1

    shaam shaam Newbie

      Hi,

       

      We have upgraded from  JBoss-5.0.1.GA to JBoss-AS-7.1.1 and everything seems to be working fine but logging doesnt seem to.

      we are using our own logging framework which was developed in java.util.logging.

      In the earlier JBoss-5,specifying   "-Djava.util.logging.config.file=C:/frameworkLogging/dev-logging.properties"  as vm args  in JBoss server launch configuration

      and dev-logging.jar in server classpath used to work.

       

      After upgradation to JBoss 7.1.1, specifying logging.properties as vm args doesnt work.

      I also tried to provide custom WEB-INF/classes/dev-logging.properties with the solution provided in the below link, but couldnt succeed.

       

      http://stackoverflow.com/questions/15258331/jboss-as-7-1-1-final-logging

       

      The default JBoss logging cannot be used as we have the custom JDBC Handler which writes the data to DB and thus require application specific logging frame work to work.

      Ihave seen most of the solutions provided in the community  are related to log4j and my requirement seems to different.

       

      looking for some help with this aspect as I have been trying hard from past couple of weeks.

       

      thanks in advance.

        • 1. Re: unable to use application level java.util.logging in JBoss AS 7.1.1
          James Perkins Master

          In JBoss AS 7 we use JBoss Log Manager which is an extension of JUL. Since your handler is based on JUL you could use the logging subsystem and create the handler as a custom-handler. You would need to create a module for your handler, then just reference it in the custom-handler.

           

          --

          James R. Perkins

          • 2. Re: unable to use application level java.util.logging in JBoss AS 7.1.1
            shaam shaam Newbie

            Hi James,

             

            Thanks for the quick response.

             

            I couldnt go with the custom handler due to the following reasons

             

            1. we wanted to upgrade to JBoss 7.1.1 without any code changes, as the same upgradation need to be done for different clients 

            2. Implementing custom-handler will again be a code change as our existing logging framework reads and configures from the properties file all the resource bundles and then creates JDBChandler, but as part of custom-handler implementation I need to define a handler which has all the properties set from the standalone.xml.

             

            Is there a way the JBoss-7.1.1 server reads "-Djava.util.logging.config.file=C:/frameworkLogging/dev-logging.properties" file at system start-up, the same way it does in JBoss-5 by specifying as vm args

             

            I also tried setting "JAVA_OPTS=%JAVA_OPTS% -Djava.util.logging.config.file=C:/frameworkLogging/dev-logging.properties" in standalone.conf.bat and creating a module and defining as ee subsystem in standalone so that I can load this module on start-up, but with no luck.

             

             

            looking forward for your valuable comments.

             

            -shaam

            • 3. Re: unable to use application level java.util.logging in JBoss AS 7.1.1
              James Perkins Master

              Hello Shaam,

              You could probably get the module to work with using a custom properties file, but it sounds like it might not be the way you want to go.

               

              This probably worked, just guessing as I don't know AS 5 all that well, because AS 5 uses log4j. You won't be able to override the JUL configuration because JBoss Log Manger is used and doesn't recognize standard JUL configuration files. It uses more of a log4j properties style of configuration.

               

              If you want all application data logged to a DB the only way to do that would be through the JBoss Log Manager. This means using the logging subsystem and/or the logging.properties in JBoss AS 7.1.1.Final. It's slightly changed in EAP 6.1.Alpha1 which keeps the logging.properties persistent with the logging subsystem, but I digress :-)

               

              If Your JDBCHandler extends java.util.logging.Handler, it can be used with with JBoss Log Manager FWIW.

               

              --

              James R. Perkins

              • 4. Re: unable to use application level java.util.logging in JBoss AS 7.1.1
                shaam shaam Newbie

                Hi James,

                 

                Can u pls explain how to make my module work using custom properties(sorry if it is dumb)

                 

                regarding persisting the logs, our application needs some specific data logged to DB and yes, the JDBC Handler we use extnds JUL Handler, also request ur inputs using JBoss Log Manager in this case.

                 

                I also tried with JBoss AS 7.1.2 hoping the per-deployment would do some magic, but couldnt suceed.

                 

                 

                Thanks in adv.

                Shaam

                • 5. Re: unable to use application level java.util.logging in JBoss AS 7.1.1
                  James Perkins Master

                  Shaam,

                  You should just be able to package the properties file in the JAR with the handler. I think you can also add a root-resource, but I'm not sure on that.

                  <module xmlns="urn:jboss:module:1.1" name="com.example.logging">
                      <resources>
                          <root-resource path="my-handlers.jar"/>
                          <root-resource path="my-props.properties"/>
                      </resources> 
                  
                      <dependencies>
                          <!-- This might not be needed -->
                          <module name="org.jboss.logmanager" services="import"/>
                      </dependencies> 
                  </module>
                  
                  

                   

                   

                  The per-deployment logging might work for you. You have to use a jboss-logmanager style of properties file, but it would allow you to configure logging in your app. It would allow runtime changes though.

                   

                  --

                  James R. Perkins

                  • 6. Re: unable to use application level java.util.logging in JBoss AS 7.1.1
                    shaam shaam Newbie

                    Hi James,

                     

                    Sorry for the late response.

                     

                    I tried packaging my jar and .properties file in module location and tried adding the <resource-root> with the properties file to my module as below,

                     

                    <module xmlns="urn:jboss:module:1.0" name="com.frameworkLogging">

                              <resources>

                                        <resource-root path="Framework-Logging.jar"/>

                                        <resource-root path="logging.properties"/>

                        </resources>

                        <dependencies>

                            <module name="javax.api"/>

                        </dependencies>

                    </module>

                     

                     

                     

                    but got the below error, seems, it does not accept the .properties file as resource.

                    Caused by: javax.xml.stream.XMLStreamException: ParseError at [row,col]:[5,45]

                    Message: Failed to add resource root 'logging.properties' at path 'logging.properties'

                              at org.jboss.modules.ModuleXmlParser.parseResourceRoot(ModuleXmlParser.java:898) [jboss-modules.jar:1.1.1.GA]

                              at org.jboss.modules.ModuleXmlParser.parseResources(ModuleXmlParser.java:854) [jboss-modules.jar:1.1.1.GA]

                              at org.jboss.modules.ModuleXmlParser.parseModuleContents(ModuleXmlParser.java:676) [jboss-modules.jar:1.1.1.GA]

                              at org.jboss.modules.ModuleXmlParser.parseDocument(ModuleXmlParser.java:548) [jboss-modules.jar:1.1.1.GA]

                              at org.jboss.modules.ModuleXmlParser.parseModuleXml(ModuleXmlParser.java:287) [jboss-modules.jar:1.1.1.GA]

                              ... 16 more

                     

                    While trying the per-deployment inJBoss 7.1.2, I placed my custom logging.properties to WEB-INF/classes/logging.properties,

                    but it does not obviously do the trick.

                    Can you please let me know how the per-deployment might work for me in detail.

                     

                    Thanks for the support.

                    • 7. Re: unable to use application level java.util.logging in JBoss AS 7.1.1
                      James Perkins Master

                      I'd really need to do some testing the get the modules working. I'm not too sure how it works to be honest.

                       

                      That looks like the correct directory. There are some bugs early on with loggers losing their configuration. Using EAP 6.1.Alpha1 or building the 7.2.0.Final tag might yeild better results. One thing to note is the logging.properies needs to be in the JBoss Logging format. It's very much like log4j, but I'm happy to help you convert it if it's in a JUL format.

                       

                      --

                      James R. Perkins

                      • 8. Re: unable to use application level java.util.logging in JBoss AS 7.1.1
                        shaam shaam Newbie

                        Hi James,

                         

                        It would be of great help if you find some space from ur valuable time.

                         

                        Also, I started setting up the JBoss 7.2.0 Final per ur instruction and I would be more than happy to take ur help in converting my logging.properties as they are in JUL format.Is it ok i send the file to ur mail id, as I dont want to share it here in the community page.

                         

                        Thanks in adv.

                        Shaam