12 Replies Latest reply on Jun 11, 2013 10:08 PM by andreypolozov

    Per deployment logging configuration in JBoss AS 7.1.3

    jahoshai

      I am trying to configure jdk logging in Jboss EAP 6.0 (AS 7.1.3).

      When I add logging.properties to my ear I get the following exception.

       

      20:31:04,853 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-1) MSC000001: Failed to start service jboss.deployment.unit."myApp.ear".POST_MODULE: org.jboss.msc.service.StartException in service jboss.deployment.unit."myApp.ear".POST_MODULE: JBAS018733: Failed to process phase POST_MODULE of deployment "myApp.ear"

              at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:123) [jboss-as-server-7.1.3.Final-redhat-4.jar:7.1.3.Final-redhat-4]

              at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.2.GA-redhat-2.jar:1.0.2.GA-redhat-2]

              at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.GA-redhat-2.jar:1.0.2.GA-redhat-2]

              at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [rt.jar:1.6.0_35]

              at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [rt.jar:1.6.0_35]

              at java.lang.Thread.run(Thread.java:662) [rt.jar:1.6.0_35]

      Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: JBAS011555: Failed to configure logging using 'logging.properties' configuration file.

              at org.jboss.as.logging.LoggingConfigurationProcessor.deploy(LoggingConfigurationProcessor.java:125)

              at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:116) [jboss-as-server-7.1.3.Final-redhat-4.jar:7.1.3.Final-redhat-4]

              ... 5 more

      Caused by: java.lang.IllegalArgumentException: className is null

              at org.jboss.logmanager.config.AbstractPropertyConfiguration.<init>(AbstractPropertyConfiguration.java:52) [jboss-logmanager-1.3.2.Final-redhat-1.jar:1.3.2.Final-redhat-1]

              at org.jboss.logmanager.config.HandlerConfigurationImpl.<init>(HandlerConfigurationImpl.java:54) [jboss-logmanager-1.3.2.Final-redhat-1.jar:1.3.2.Final-redhat-1]

              at org.jboss.logmanager.config.LogContextConfigurationImpl.addHandlerConfiguration(LogContextConfigurationImpl.java:138) [jboss-logmanager-1.3.2.Final-redhat-1.jar:1.3.2.Final-redhat-1]

              at org.jboss.logmanager.PropertyConfigurator.configureHandler(PropertyConfigurator.java:477) [jboss-logmanager-1.3.2.Final-redhat-1.jar:1.3.2.Final-redhat-1]

              at org.jboss.logmanager.PropertyConfigurator.configure(PropertyConfigurator.java:379) [jboss-logmanager-1.3.2.Final-redhat-1.jar:1.3.2.Final-redhat-1]

              at org.jboss.logmanager.PropertyConfigurator.configure(PropertyConfigurator.java:92) [jboss-logmanager-1.3.2.Final-redhat-1.jar:1.3.2.Final-redhat-1]

              at org.jboss.as.logging.LoggingConfigurationProcessor.deploy(LoggingConfigurationProcessor.java:122)

              ... 6 more

       

       

      And my logging.properties file is

       

      handlers = java.util.logging.FileHandler

       

      # Set the default logging level for the root logger

      .level = INFO

       

      # Set the default logging level for new ConsoleHandler instances

       

      # Set the default logging level for new FileHandler instances

      java.util.logging.FileHandler.level = INFO

       

      # Set the default formatter for new ConsoleHandler instances

       

      # default file output is in user's home directory.

      java.util.logging.FileHandler.pattern = myApp_test.log

      java.util.logging.FileHandler.limit = 50000

      java.util.logging.FileHandler.count = 1

      java.util.logging.FileHandler.formatter = java.util.logging.SimpleFormatter

       

      # Set the default logging level for the logger named com.mycompany

      com.myApp.core.level = INFO

       

       

      Please help me out in resolving this issue.

        • 1. Re: Per deployment logging configuration in JBoss AS 7.1.3
          jamezp

          The JBoss Log Manager doesn't use the same configuration style as JUL does.

           

          The configuration would look like:

           

          # Set the default logging level for the logger named com.mycompany
          loggers=com.myApp.core
          
          # Set the default logging level for the root logger
          logger.level=INFO
          
          logger.com.myApp.core.level=INFO
          
          
          handlers=FILE
          
          # Set the default logging level for new FileHandler instances
          handler.FILE=java.util.logging.FileHandler
          handler.FILE.level=INFO
          handler.FILE.properties=pattern,limit,count
          handler.FILE.pattern=myApp_test.log
          handler.FILE.limit=50000
          handler.FILE.count=1
          handler.FILE.formatter=SIMPLE 
          
          formatter.SIMPLE=java.util.logging.SimpleFormatter
          
          

           

          You don't have to use the JUL handlers though. JBoss Log Manager has handlers too that can be used as well as a PatternFormatter that's much better than the SimpleFormatter IMO.

           

          Example:

           

          # Set the default logging level for the logger named com.mycompany
          loggers=com.myApp.core
          
          # Set the default logging level for the root logger
          logger.level=INFO
          
          logger.com.myApp.core.level=INFO
          
          handlers=FILE
          
          # File handler configuration
          handler.FILE=org.jboss.logmanager.handlers.SizeRotatingFileHandler
          handler.FILE.level=DEBUG
          handler.FILE.properties=autoFlush,fileName,rotateSize,maxBackupIndex
          handler.FILE.autoFlush=true
          handler.FILE.fileName=${jboss.server.log.dir}/myApp_test.log
          handler.FILE.rotateSize=50k
          handler.FILE.maxBackupIndex=5
          handler.FILE.formatter=PATTERN
          
          # Formatter pattern configuration
          formatter.PATTERN=org.jboss.logmanager.formatters.PatternFormatter
          formatter.PATTERN.properties=pattern
          formatter.PATTERN.pattern=%d{HH:mm:ss,SSS} %-5p [%c] %s%E%n
          

           

          --

          James R. Perkins

          1 of 1 people found this helpful
          • 2. Re: Per deployment logging configuration in JBoss AS 7.1.3
            jahoshai

            Thanks James for your reply.

             

            I modified my logging.properties as mentioned by you. I used JBoss log manager handlers.

            Now my ear is getting deployed with out any error.

            But nothing is being logged in the file.

             

            Below is my logging.properties

             

            # Set the default logging level for the logger named com.mycompany

            loggers=com.myApp.core

             

            # Set the default logging level for the root logger

            logger.level=INFO

             

            logger.com.myApp.core.level=INFO

             

            handlers=FILE

             

            # File handler configuration

            handler.FILE=org.jboss.logmanager.handlers.SizeRotatingFileHandler

            handler.FILE.level=INFO

            handler.FILE.properties=autoFlush,fileName,rotateSize,maxBackupIndex

            handler.FILE.autoFlush=true

            handler.FILE.fileName=${jboss.server.log.dir}/myApp_test.log

            handler.FILE.rotateSize=50000

            handler.FILE.maxBackupIndex=5

            handler.FILE.formatter=PATTERN

             

            # Formatter pattern configuration

            formatter.PATTERN=org.jboss.logmanager.formatters.PatternFormatter

            formatter.PATTERN.properties=pattern

            formatter.PATTERN.pattern=%d{HH:mm:ss,SSS} %-5p [%c] %s%E%n

            • 3. Re: Per deployment logging configuration in JBoss AS 7.1.3
              jamezp

              Is the file getting created in the log directory? If so that does indicate the configuration is at least being done.

               

              The root logger is set to level INFO so it should be logging anything INFO or higher. The configuration looks okay too. I guess there is no real need for the logger.com.myApp.core.level property, but it also won't hurt anything.

               

              --

              James R. Perkins

              • 4. Re: Per deployment logging configuration in JBoss AS 7.1.3
                jahoshai

                The file is getting created in the log directory but nothing is getting logged.

                If I use JUL handlers I get the following error when deploying my app.

                 

                00:52:34,192 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-1) MSC000001: Failed to start service jboss.deployment.unit."myApp.ear".POST_MODULE: org.jboss.msc.service.StartException in service jboss.deployment.unit."myApp.ear".POST_MODULE: JBAS018733: Failed to process phase POST_MODULE of deployment "myApp.ear"

                        at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:123) [jboss-as-server-7.1.3.Final-redhat-4.jar:7.1.3.Final-redhat-4]

                        at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.2.GA-redhat-2.jar:1.0.2.GA-redhat-2]

                        at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.GA-redhat-2.jar:1.0.2.GA-redhat-2]

                        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [rt.jar:1.6.0_35]

                        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [rt.jar:1.6.0_35]

                        at java.lang.Thread.run(Thread.java:662) [rt.jar:1.6.0_35]

                Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: JBAS011555: Failed to configure logging using 'logging.properties' configuration file.

                        at org.jboss.as.logging.LoggingConfigurationProcessor.deploy(LoggingConfigurationProcessor.java:125)

                        at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:116) [jboss-as-server-7.1.3.Final-redhat-4.jar:7.1.3.Final-redhat-4]

                        ... 5 more

                Caused by: java.lang.IllegalArgumentException: className is null

                        at org.jboss.logmanager.config.AbstractPropertyConfiguration.<init>(AbstractPropertyConfiguration.java:52) [jboss-logmanager-1.3.2.Final-redhat-1.jar:1.3.2.Final-redhat-1]

                        at org.jboss.logmanager.config.FormatterConfigurationImpl.<init>(FormatterConfigurationImpl.java:33) [jboss-logmanager-1.3.2.Final-redhat-1.jar:1.3.2.Final-redhat-1]

                        at org.jboss.logmanager.config.LogContextConfigurationImpl.addFormatterConfiguration(LogContextConfigurationImpl.java:167) [jboss-logmanager-1.3.2.Final-redhat-1.jar:1.3.2.Final-redhat-1]

                        at org.jboss.logmanager.PropertyConfigurator.configureFormatter(PropertyConfigurator.java:451) [jboss-logmanager-1.3.2.Final-redhat-1.jar:1.3.2.Final-redhat-1]

                        at org.jboss.logmanager.PropertyConfigurator.configureHandler(PropertyConfigurator.java:493) [jboss-logmanager-1.3.2.Final-redhat-1.jar:1.3.2.Final-redhat-1]

                        at org.jboss.logmanager.PropertyConfigurator.configure(PropertyConfigurator.java:379) [jboss-logmanager-1.3.2.Final-redhat-1.jar:1.3.2.Final-redhat-1]

                        at org.jboss.logmanager.PropertyConfigurator.configure(PropertyConfigurator.java:92) [jboss-logmanager-1.3.2.Final-redhat-1.jar:1.3.2.Final-redhat-1]

                        at org.jboss.as.logging.LoggingConfigurationProcessor.deploy(LoggingConfigurationProcessor.java:122)

                        ... 6 more

                 

                 

                This is my logging.properties file which uses JUL Handlers

                 

                # Set the default logging level for the logger named com.mycompany

                loggers=com.myApp.core

                # Set the default logging level for the root logger

                logger.level=INFO

                logger.com.myApp.core.level=INFO

                 

                handlers=FILE

                 

                # Set the default logging level for new FileHandler instances

                handler.FILE=java.util.logging.FileHandler

                handler.FILE.level=INFO

                handler.FILE.properties=pattern,limit,count

                handler.FILE.pattern=myApp_test.log

                handler.FILE.limit=50000

                handler.FILE.count=1

                handler.FILE.formatter=SIMPLE

                 

                formatter.SIMPLE=java.util.logging.SimpleFormatter

                 

                 

                Just now I tried it on JBoss AS 7.1.1 community edition, and to my surprise the logging worked fine.

                Actually the EAP version on which I am facing issue is a trial version which has got expired few days back. I hope that wont cause any issues like this.

                • 5. Re: Per deployment logging configuration in JBoss AS 7.1.3
                  jamezp

                  Now that I think about it, that JUL handler won't work. Only because it has no getter/setter methods for the properties you're trying to set. You will have to use either the org.jboss.logmanager.FileHandler, org.jboss.logmanager.PeriodicRotatingFileHandler or org.jboss.logmanager.SizeRotatingFileHandler.

                   

                  The only reason that nothing would be logged to a file is if there is nothing to be logged. Try setting the file level and the root logger level to TRACE and see if you get anything.

                   

                  You shouldn't see any deployment errors in 7.1.1.Final, but it also doesn't have per-logging deployment so it's not attempting to configure logging for your deployment. An expired EAP shouldn't cause a logging error at all. TBH, I'm not even sure what happens when a trial expires.

                   

                  --

                  James R. Perkins

                  • 6. Re: Per deployment logging configuration in JBoss AS 7.1.3
                    rohanemmanuel

                    i was tryin the same thing on 7.1.2.FINAL....were you able to log app specific logs into your log file?

                    Regards ,

                    Rohan

                    • 7. Re: Per deployment logging configuration in JBoss AS 7.1.3
                      jahoshai

                      No. This issue was not fixed for me. For time being I have disabled per deployment logging.

                      • 8. Re: Per deployment logging configuration in JBoss AS 7.1.3
                        andreypolozov

                        I'm trying to make per-deployment log working too.

                        So  far search gives me this topic, and many recomendations that start with "set org.jboss.as.logging.per-deployment to false..."

                        Has this feature ever worked?

                        Can anyone point me to some detailed example of using it successfully?

                        • 9. Re: Per deployment logging configuration in JBoss AS 7.1.3
                          jamezp

                          What version of JBoss AS or WildFly are you using? Setting the org.jboss.logging.per-deployment to false will disable the per-deployment logging and you'll be required to configure it yourself or your log manager of choice will need to pick up the configuration and process it.

                           

                          --

                          James R. Perkins

                          • 10. Re: Per deployment logging configuration in JBoss AS 7.1.3
                            andreypolozov

                            (I apologize if I break any rules by "stealing" the topic.)

                            Can I ask some generic questions about per-deployment logging?

                             

                            1. What can and cannot be configured per deployment? Does per-deployment logging configuration inherit anything from the server-wide configuration?

                             

                            2. Let's say I have 2 web apps, each has overlapping packages the Logger gets pulled by full class name:

                             

                            package com.mycompany.myapp.common;

                            ...

                            public class SomeUtility {

                            private static final Logger logger = Logger.getLogger(SomeUtility.class.getName());

                            ...

                              logger.info("something");

                             

                            Both apps would use that class internally.

                            Would this feature give me ability to log messages from that class into separate file for each web app if I provide different configuration for each web app?

                             

                            3. Does per-deployment logging work with JUL as well as Log4j? As far as I understand, JBoss provides a bridge from JUL to log4j. Our application uses java.util.logging, but with JBoss AS 5 we had everything configured in jboss-log4j.xml (we used TCLMCFilter). Is it possible to provide the per-deployment configuration, which would be common for  log4j and jul?

                             

                            4. What's the scope of loggers/logmanagers configured per deployment? Do they live in deployment's classloader or in the global one?

                             

                            Thanks!

                             

                            P.S. I've been trying to migrate from AS 5.2 to EAP 6.01. But once bumped into the per-deployment issue - decided to move toward EAP 6.1...

                             

                            Message was edited by: Andrey Polozov

                            • 11. Re: Per deployment logging configuration in JBoss AS 7.1.3
                              jamezp

                              Ideally a new topic should probably be started, but I'll go ahead and answer here.

                              1. What can and cannot be configured per deployment? Does per-deployment logging configuration inherit anything from the server-wide configuration?

                              The per-deployment logging configuration will configure the log manager for your application with the settings you have in the configuration file. Basically anything that is allowed in a log4j.xml, log4j.properties or JBoss version of a logging.properties file is allowed.

                               

                               

                              2. Let's say I have 2 web apps, each has overlapping packages the Logger gets pulled by full class name:

                               

                              package com.mycompany.myapp.common;

                              ...

                              public class SomeUtility {

                              private static final Logger logger = Logger.getLogger(SomeUtility.class.getName());

                              ...

                                logger.info("something");

                               

                              Both apps would use that class internally.

                              Would this feature give me ability to log messages from that class into separate file for each web app if I provide different configuration for each web app?

                               

                              It depends. If the common file is in a module or in an EAR/lib directory, then no. The first application that accesses the class is the one that will setup the configuration for the logger. If however you put the common library in the WEB-INF/lib of a WAR then that would be possible.

                               

                               

                              3. Does per-deployment logging work with JUL as well as Log4j? As far as I understand, JBoss provides a bridge from JUL to log4j. Our application uses java.util.logging, but with JBoss AS 5 we had everything configured in jboss-log4j.xml (we used TCLMCFilter). Is it possible to provide the per-deployment configuration, which would be common for  log4j and jul?

                              The per-deployment logging is only used with log4j or the jboss-logmanager. In the end everything gets configured through the JBoss Log Manager which is an extension of j.u.l.LogManager. In short, it doesn't matter what logging framework/facade you use it should work with either a log4j configuration file or logging.properties (in JBoss Log Manager format). To be honest I would suggest using the logging.properties instead of a log4j configuration. I'd be happy to help convert your jboss-log4j.xml to a logging.properties file if you would like.

                               

                              There is no current TCLMCFilter.

                               

                               

                              4. What's the scope of loggers/logmanagers configured per deployment? Do they live in deployment's classloader or in the global one?

                              Essentially what happens is a new LogContext is created for your deployment. It uses your deployments classloader to determine which LogContext should be used.

                               

                               

                              The per-deployment logging is completely optional. I would suggest using the logging subsystem over per-deployment logging so that you can make runtime changes to the logging configuration. With EAP 6.1 there is a logging-profile option that allows you to assign a profile to a deployment. This would be similar to per-logging deployment, but you can make runtime changes. There is some documentation of logging-profiles here.

                               

                              Hope this helps.

                               

                              --

                              James R. Perkins

                              • 12. Re: Per deployment logging configuration in JBoss AS 7.1.3
                                andreypolozov

                                Thank you so much James!

                                I'll start another topic regarding per-deployment logging and profiles.