4 Replies Latest reply on Sep 23, 2014 5:34 AM by windigo

    Per-deployment logging in EAP 6.1.0.GA: no console output

    fabioo Newbie


      Hello. I'm migrating a .war application from AS 7.1 to EAP 6.1.0.GA, but I'm not able to log to console (other appenders just work) using log4j and per-deployment logging. I can reproduce the issue with a quickstart:

       

      • Import the jboss-eap-6.1.0-quickstarts/log4j project (I've set version.org.jboss.spec.jboss.javaee.6.0 = 3.0.2.Final, for the records)
        • Everything's fine, logging to console is ok
      • Create a log4j.properties (or .xml, I had the same issues) that logs both to a console appender and a file appender

       

      log4j.rootLogger=INFO, file, console
       
      log4j.appender.file=org.apache.log4j.RollingFileAppender
      [...]
       
      log4j.appender.console=org.apache.log4j.ConsoleAppender
      [...]
      
      

       

      • Deploy and run

       

       

      Observed: the logs are written properly to the specified file, but nothing is shown on the console. No configuration warnings or errors are shown during the server/app startup.

       

      I've spent several hours searching for a solution but the only suggestions i got were related to "disabling per-deployment logging", which is not what I want (I like this feature a lot)!

       

       

      Thank you in advance,

      Fabio

        • 1. Re: Per-deployment logging in EAP 6.1.0.GA: no console output
          James Perkins Master

          There is a bug in the log4j-jboss-logmanager which bridges log4j to JBoss Log Manager. The bug is fixed in the upstream source, but a release hasn't been made yet.

           

          If you're only using the ConsoleAppender and RollingFileAppender you could use a logging.properties formatted for the JBoss Log Manager. It would look something like the following:

           

          # Additional loggers to configure (the root logger is always configured)
          loggers=
          
          
          logger.level=INFO
          logger.handlers=CONSOLE,FILE
          
          
          handler.CONSOLE=org.jboss.logmanager.handlers.ConsoleHandler
          handler.CONSOLE.level=INFO
          handler.CONSOLE.formatter=CONSOLE
          handler.CONSOLE.properties=autoFlush,target
          handler.CONSOLE.autoFlush=true
          handler.CONSOLE.target=SYSTEM_OUT 
          
          handler.FILE=org.jboss.logmanager.handlers.PeriodicRotatingFileHandler
          handler.FILE.level=ALL
          handler.FILE.formatter=FILE
          handler.FILE.properties=autoFlush,append,fileName,suffix
          handler.FILE.constructorProperties=fileName,append
          handler.FILE.autoFlush=true
          handler.FILE.append=true
          handler.FILE.fileName=${jboss.server.log.dir}/deployment.log
          handler.FILE.suffix=.yyyy-MM-dd 
          
          formatter.CONSOLE=org.jboss.logmanager.formatters.PatternFormatter
          formatter.CONSOLE.properties=pattern
          formatter.CONSOLE.pattern=%K{level}%d{HH\:mm\:ss,SSS} %-5p [%c] (%t) %s%E%n 
          
          formatter.FILE=org.jboss.logmanager.formatters.PatternFormatter
          formatter.FILE.properties=pattern
          formatter.FILE.constructorProperties=pattern
          formatter.FILE.pattern=%d{HH\:mm\:ss,SSS} %-5p [%c] (%t) %s%E%n
          

           

           

          --

          James R. Perkins

          • 2. Re: Per-deployment logging in EAP 6.1.0.GA: no console output
            fabioo Newbie

            Ok, thanks for the explanation, your example has been really useful. Just a small note: there's an extra whitespace at the end of the line

             

            handler.CONSOLE.target=SYSTEM_OUT

             

            which raises a "No enum constant org.jboss.logmanager.handlers.ConsoleHandler.Target.SYSTEM_OUT" exception (just in case someone else copies/pastes it!)

             

             

            Fabio

            • 3. Re: Per-deployment logging in EAP 6.1.0.GA: no console output
              James Perkins Master

              Nice catch, thanks! I've created a JIRA for the logmanager to fix that. It's a bug that it's not trimming the property string values.

               

              --

              James R. Perkins

              • 4. Re: Per-deployment logging in EAP 6.1.0.GA: no console output
                windigo Newbie

                Hi,

                 

                is the console-bug in the log4j-jboss-logmanager already fixed? I can't fnd a jira-issue for that.

                I'm also trying to configure a log4j.properties with multiple file-appenders and additivity-flags. Is this also possible in a logging.properties-file?

                 

                 

                thx in advance

                Felix