9 Replies Latest reply on Jan 30, 2017 12:58 PM by James Perkins

    System.out.println messages in JBoss EAP 6.2 logs

    Menelaus Perdikeas Newbie

      I am deploying to JBoss EAP 6.

      My application is issuing some `System.out.println` calls that I would like to see on the JBoss console.



      Currently I don't see any messages there. My WAR has a `logging.properties` file with the following contents:





          org.apache.catalina.core.ContainerBase.[Catalina].level = INFO

          org.apache.catalina.core.ContainerBase.[Catalina].handlers = java.util.logging.ConsoleHandler



      I need those settings to debug some situations, e.g. like this one:





      ... as the output on the JBoss console is too terse otherwise.


      When the `logging.properties` file is present I don't see my `System.out.println` messages in JBoss console. When I remove the `logging.properties` file from the WAR I see them.


      Why is that? What is wrong with my `logging.properties` file that prevents my `System.out.println` messages to show up in JBoss console?

        • 1. Re: System.out.println messages in JBoss EAP 6.2 logs
          Abhijit Humbe Master

          The logging.properties you are using seems more specific to tomcat server. Can you give a try with following property file:




          log4j.appender.appenderA.layout.ConversionPattern=[%d{MM/dd HH:mm:ss.SSS}]      [%p]%c{1}:%L - %m%n










          log4j.appender.myFileAppender.layout.ConversionPattern=[%d{MM/dd HH:mm:ss.SSS}]      [%p]%c{1}:%L - %m%n


          log4j.category.aaa.bbb.ChatServer=TRACE, myFileAppender




          log4j.rootLogger=TRACE, appenderA

          • 2. Re: System.out.println messages in JBoss EAP 6.2 logs
            James Perkins Master

            You don't actually need a logging.properties to configure logging for your deployment. The logging.properties you're using is a JUL version which also does not work with per-deployment logging in JBoss EAP. You can use CLI to turn on the debugging for these categories to the console-handler.


            Example CLI commands:

            /subsystem=logging/logger=org.apache.catalina.session:add(level=ALL)   /subsystem=logging/logger=org.apache.catalina.core.ContainerBase.[Catalina]:add(level=INFO)  /subsystem=logging/console-handler=CONSOLE:write-attribute(name=level, value=ALL) 


            James R. Perkins

            • 3. Re: System.out.println messages in JBoss EAP 6.2 logs
              Menelaus Perdikeas Newbie

              @Abhijit Humbe

              I am afraid this doesn't work. But more importantly, where is some description of the kind of logging.properties to use with JBoss? This seems like a nightmare to configure for such a simple task! I simply have some plain old blessed System.out.println statements I want to see in my console output. If I remove the logging.properties file entirely it does work but the question remains, assuming I want to do some kind of logging configuration where is a JBoss-provided description of the format I am supposed to use in my logging.properties file ?

              • 4. Re: System.out.println messages in JBoss EAP 6.2 logs
                Menelaus Perdikeas Newbie

                Thanks for the reply, but I don't want to have to study and learn a cryptic DSL to configure my logging. That's what logging.properties files are for and you can put the in source control and everything. Plus you can have different preferences per deployment which is the way to go. Since you say that logging.properties in the JUL style are not working, would you happen to know what is the format that works for JBoss? Is it some SL4J / Log4J format? Mind you I don't use any logging framework at all, just simple System.out.printf statements.

                • 5. Re: System.out.println messages in JBoss EAP 6.2 logs
                  James Perkins Master

                  If you don't use any logging framework a logging configuration will not be of much use to you. There is one caveat however that JBoss EAP 6 does wrap System.out and System.err in loggers so it *may* work.


                  I'd argue the DSL is not all that cryptic as it would the the same DSL you'd use to make any change to JBoss EAP 6 or EAP 7. It's the standard CLI syntax for all management changes. The benefit of using the logging subsystem is it will not require a redeployment of your application if you want to make changes to logging. By using a logging.properties a file if you want to say turn on debug logging you'd have to make the change, then redeploy your application.


                  JBoss EAP 6 uses JBoss Log Manager which is an extension of JUL. The logging.properties file uses more of a log4j.properties syntax however. A similar configuration to what you have would look something like this:


















                  formatter.COLOR-PATTERN.pattern=%K{level}%d{HH\:mm\:ss,SSS} %-5p [%c] (%t) %s%e%n



                  The main change here is using the org.jboss.logmanager.handlers.ConsoleHandler so the same locks will be used from the server when writing to the console and the log output will similar. You'd also probably want to the the console handler the root logger. In your example you'd only ever see log messages from the org.apache.catalina.core.ContainerBase.[Catalina] logger since it's the only logger the handler is assigned to.


                  Hope this helps.



                  James R. Perkins

                  • 6. Re: System.out.println messages in JBoss EAP 6.2 logs
                    Menelaus Perdikeas Newbie

                    Thanks this does work but where is this format defined? Without an explanation of the syntax / structure of these files one cannot have a mental model to understand them or (much less) write one's own from scratch. The documentation at: Chapter 14. The Logging Subsystem  is absolutely horrible (I couldn't find a single logging.properties example) and the presentation / implementation positively abysmal (e.g. all searches are global, you can't just search a specific chapter or documentation book).

                    • 7. Re: System.out.println messages in JBoss EAP 6.2 logs
                      James Perkins Master

                      The format is defined here:



                      formatter.COLOR-PATTERN.pattern=%K{level}%d{HH\:mm\:ss,SSS} %-5p [%c] (%t) %s%e%n


                      That document is documenting how to configure logging in the logging subsystem not how to write a logging.properties file. I will admit there is a lack of documentation on how to write a JBoss Log Manager specific logging.properties file. However that is not that goal of that chapter.


                      Again it's suggested to use the logging subsystem to configure logging as it doesn't require redeployment of your application to make changes to the logging configuration.



                      James R. Perkins

                      • 8. Re: System.out.println messages in JBoss EAP 6.2 logs
                        Menelaus Perdikeas Newbie

                        Actually when I asked "where is the format defined?" I was referring not to the logging format itself but rather to the format / syntax and names / options available to the declarative "language" that is used to write the logging.properties file. Also, for the record the sample you provided did seem to work in JBoss EAP 6.4 but when I deployed to JBoss EAP 6.2 (with the exact same logging.properties file) I again lost all output of System.out.printf commands.

                        • 9. Re: System.out.println messages in JBoss EAP 6.2 logs
                          James Perkins Master

                          Section 4.3.1 of the EAP 7 documentation describes the logging.properties file format Chapter 4. Logging - Red Hat Customer Portal . The format is the same for EAP 6.x as well.


                          It's possible there was a bug fixed at some point between JBoss EAP 6.2 and 6.4. I do recall some bugs around using System.out or System.err in per-deployment logging. You may want to contact support as there may be a patch available for EAP 6.2.


                          Just as a reminder too using System.out or System.err is not generally configured by a log manager. The only reason it is in EAP is because the streams are wrapped in a logger.



                          James R. Perkins