8 Replies Latest reply on Sep 15, 2006 12:51 PM by Ramdas Hegde

    Rolling over JBoss console log

    Ramdas Hegde Newbie

      Hello

      I am using JBoss AS 3.2.6. I have the JBOSS_CONSOLE set to redirect console output to a file. I have tried setting log4j configuration in the server/myapp/conf/log4j.xml file but it does not seem to work.
      Where could i specify the rollover parameters for the console log file?

      Thanks

      Ramdas

        • 1. Re: Rolling over JBoss console log
          Peter Goetz Newbie

          Hi Ramdas,

          what does not work when changing the configuration of log4j.xml. Normally this is the place where you put your configuration. What have you changed and what doesn't work?

          Peter

          • 2. Re: Rolling over JBoss console log
            Ramdas Hegde Newbie

            Peter,

            In my configuration, when JBoss starts, the console output is redirected to a file (using start_jboss.sh > console.log 2>&1).

            I am trying to find a way to rollover the log file which is being created as a result of redirecting console output.
            I realize that the format of the data output to the console is being influenced by the following in log4j.xml

            <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
             <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
             <param name="Target" value="System.out"/>
             <param name="Threshold" value="INFO"/>
            
             <layout class="org.apache.log4j.PatternLayout">
             <!-- The default pattern: Date Priority [Category] Message\n -->
             <param name="ConversionPattern" value="%d %-5p [%c{1}] %m%n"/>
             </layout>
             </appender>
            

            I tried using an element in log4j.xml similar to the one i have used for creating and rolling over the JBoss server.log. But it does not have any influence on console.log - which i think makes sense since the console.log file is not created by log4j but by my shelll script which is redirecting the console output.
            I am trying to find if there is a way to capture the console output to a file and also rollover that file every day.

            Thanks

            Ramdas

            • 3. Re: Rolling over JBoss console log
              Peter Goetz Newbie

              Hi Ramdas,

              I'm not sure if I understand you right. But if you want to capture the output to the console in your file, why don't you change the "CONSOLE" appender in log4j.xml to use a RollingFileAppender like the "FILE" appender? Then you could remove the redirect from the shell to console.log and configure logging via log4j.

              If I got you wrong, please give me some more input.

              Peter

              • 4. Re: Rolling over JBoss console log
                Ramdas Hegde Newbie

                Peter,

                I tried your suggestion but there was no output to the log. Here is what i used:

                 <appender name="CONSOLE" class="org.jboss.logging.appender.RollingFileAppender"/>
                 <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
                 <param name="File" value="${jboss.server.home.dir}/log/console1.log"/>
                 <param name="Threshold" value="INFO"/>
                 <param name="Target" value="System.out"/>
                 <param name="Append" value="false"/>
                 <layout class="org.apache.log4j.PatternLayout">
                 <!-- The default pattern: Date Priority [Category] Message\n -->
                 <param name="ConversionPattern" value="%d %-5p [%c{1}] %m%n"/>
                 </layout>
                 </appender>
                


                What am i doing wrong here?

                Thanks

                Ramdas

                • 5. Re: Rolling over JBoss console log
                  Peter Goetz Newbie

                  Hi Ramdas,

                  there are some errors in your configuration. First you finish the opening appender tag with "/>". That brings a SaxParseException. Then you have the param "Target" that is not possible for the FileAppender.
                  Apart from that your configuration works for me.

                  Peter

                  • 6. Re: Rolling over JBoss console log
                    Ramdas Hegde Newbie

                    Peter,

                    I corrected the extra tag for the appender and removed the target - but now my output will be the same as server.log.
                    I am wondering, if i remove the "Target" parameter, how different is this going to be from creating the application server log. The console output captures stuff which the server.log does not - in particular JVM related messages and that is the stuff that i want to get into a file which can be rolled over.

                    Thanks

                    Ramdas

                    • 7. Re: Rolling over JBoss console log
                      Peter Goetz Newbie

                      Hi Ramdas,

                      the configuration is not different from the server.log at all.
                      What messages are given out on the console that do not appear in the server.log (if you have the same threshold defined)? I haven't noticed anything different yet.

                      Peter

                      • 8. Re: Rolling over JBoss console log
                        Ramdas Hegde Newbie

                        The output thrown to JBOSS_CONSOLE is quite different and we have noticed that when we have had JVM crashes, the JVM messages are dumped in the console output and not in server.log. If you redirect JBOSS_CONSOLE to a file instead of /dev/null, you will see the differences.

                        Thanks

                        Ramdas