3 Replies Latest reply on Oct 11, 2010 8:08 PM by peterj

    Why is System.out going to a file appender?

    forumer

      I am using JBoss 5.1.0.GA

       

      I can't figure out why System.out statements are going to file appender in log4j.xml? I understand that JBoss sends these statements to CONSOLE appender. In jobss-log4j.xml, I have commented out references to "CONSOLE" everywhere except the definition of CONSOLE appender itself, but I still see STDOUT statements in file appender.

       

      What am I doing wrong?

       

      I saw an oblique hint an a JIRA saying that CONSOLE goes to all appenders and this has been fixed in JBoss 6.0 Is this true and does this mean that there is no work-around in JBoss 5.1.0.GA?

       

      Thank you!

        • 1. Re: Why is System.out going to a file appender?
          peterj

          JBoss AS captures output to stdout and sterr and redirects it to Log4J as INFO and ERROR log messages, respectively. One reason why this is done is because Java EE applications are not supposed to be writing to the file system.

           

          I'm not sure how, or if, this has changed in AS 6.

          • 2. Re: Why is System.out going to a file appender?
            forumer

            For completeness, which appenders are stdout and stderr redirected to as INFO and ERROR?

             

            Thanks!

            • 3. Re: Why is System.out going to a file appender?
              peterj

              The simple answer: all of them.

               

              The detailed answer: in Log4J there are two gatekeepers. First, the category settings (the first gatekeeper) determine whether or not a message is to be logged. If the decision is to log the message, then that logged message is sent to every appender (the second gatekeeper) which will then decide if it should output that log message. In both cases, the log level is used as the deciding factor. Text written to stdout and stderr bypasses the first gateway (the assumption is that the text is to be logged), and is handed to each appender. Thus, there is no such thing as "redirecting to an appender", all appenders get equal access to all messages to be logged. This is a fairly simple system, but there are a lot of implications, especially in terms of performance.