6 Replies Latest reply on Nov 26, 2008 1:28 AM by ran_sushmi

    JBOSS log rotation

    ran_sushmi

      I, have a query as to how is log rotation configured in the file which is I guess, log4j.xml. I, wanted to have a complete understanding of the entries in the configuration file as this looks to be a big file.

      I hope, my question is clear.

      Please, help in solving the doubt.

      regards

        • 1. Re: JBOSS log rotation
          jaikiran

          The log4j.xml is supported by the Log4j framework. The Log4j manual http://logging.apache.org/log4j/1.2/manual.html will help you get started with this.

          • 2. Re: JBOSS log rotation
            ran_sushmi

            hi,

            thanks, for your answer. This was helpful, but there is this code in our JBOSS application 'log4j.xml' file which is difficult to understand. I am pasting the initial contents of the file off which I am not able to make out much. The contents are:-

            -------------------------------------------------------------------------------------------
            <?xml version="1.0" encoding="UTF-8"?>
            <!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">

            <!-- ===================================================================== -->
            <!-- -->
            <!-- Log4j Configuration -->
            <!-- -->
            <!-- ===================================================================== -->

            <!-- $Id: log4j.xml,v 1.13.2.13 2004/05/11 16:33:46 belaban Exp $ -->

            <!--
            | For more configuration infromation and examples see the Jakarta Log4j
            | owebsite: http://jakarta.apache.org/log4j
            -->


            <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">

            <!-- ================================= -->
            <!-- Preserve messages in a local file -->
            <!-- ================================= -->

            <!-- A time/date based rolling appender -->





            <!-- Rollover at midnight each day
            <param name="DatePattern" value="'.'yyyy-MM-dd"/>
            -->

            <!-- Rollover at the top of each hour
            <param name="DatePattern" value="'.'yyyy-MM-dd-HH"/>
            -->


            <!-- The default pattern: Date Priority [Category] Message\n -->


            <!-- The full pattern: Date MS Priority [Category] (Thread:NDC) Message\n

            -->



            <!-- A size based file rolling appender -->












            <!-- ============================== -->
            <!-- Append messages to the console -->
            <!-- ============================== -->







            <!-- The default pattern: Date Priority [Category] Message\n -->













            <!-- ====================== -->
            <!-- More Appender examples -->
            <!-- ====================== -->

            <!-- Buffer events and log them asynchronously


            <appender-ref ref="FILEDATE"/>
            <appender-ref ref="CONSOLE"/>
            <appender-ref ref="SMTP"/>

            -->

            <!-- EMail events to an administrator












            -->

            <!-- Syslog events






            -->
            ---------------------------------------------------------------------------------------------

            Can, the lines of the code be explained. By the way, is there any way to upload a file on the forum.

            I hope, my question is clear.

            Please, help in solving the doubt.

            regards

            • 3. Re: JBOSS log rotation
              jaikiran

              Please repost the contents of the file by enclosing the xml content in a code block by using the "Code" button in the message editor window. Please use the Preview button before posting, to ensure that the post is correctly formatted.


              By the way, is there any way to upload a file on the forum.


              No, the forum does not have that support.

              • 4. Re: JBOSS log rotation
                ran_sushmi

                 

                hi,
                
                thanks, for your answer. This was helpful, but there is this code in our JBOSS application 'log4j.xml' file which is difficult to understand. I am pasting the initial contents of the file off which I am not able to make out much. The contents are:-
                
                -------------------------------------------------------------------------------------------
                <?xml version="1.0" encoding="UTF-8"?>
                <!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
                
                <!-- ===================================================================== -->
                <!-- -->
                <!-- Log4j Configuration -->
                <!-- -->
                <!-- ===================================================================== -->
                
                <!-- $Id: log4j.xml,v 1.13.2.13 2004/05/11 16:33:46 belaban Exp $ -->
                
                <!--
                 | For more configuration infromation and examples see the Jakarta Log4j
                 | owebsite: http://jakarta.apache.org/log4j
                 -->
                
                
                <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">
                
                 <!-- ================================= -->
                 <!-- Preserve messages in a local file -->
                 <!-- ================================= -->
                
                 <!-- A time/date based rolling appender -->
                 <appender name="FILEDATE" class="org.jboss.logging.appender.DailyRollingFileAppender">
                 <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
                 <param name="File" value="${jboss.server.home.dir}/log/server.log"/>
                 <param name="Append" value="false"/>
                
                 <!-- Rollover at midnight each day
                 <param name="DatePattern" value="'.'yyyy-MM-dd"/>
                 -->
                
                 <!-- Rollover at the top of each hour
                 <param name="DatePattern" value="'.'yyyy-MM-dd-HH"/>
                 -->
                
                 <layout class="org.apache.log4j.PatternLayout">
                 <!-- The default pattern: Date Priority [Category] Message\n -->
                 <param name="ConversionPattern" value="%d %-5p [%c] %m%n"/>
                
                 <!-- The full pattern: Date MS Priority [Category] (Thread:NDC) Message\n
                 <param name="ConversionPattern" value="%d %-5r %-5p [%c] (%t:%x) %m%n"/>
                 -->
                 </layout>
                 </appender>
                
                 <!-- A size based file rolling appender -->
                 <appender name="FILE" class="org.jboss.logging.appender.RollingFileAppender">
                 <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
                 <param name="File" value="${jboss.server.home.dir}/log/server.log"/>
                 <param name="Append" value="false"/>
                 <param name="MaxFileSize" value="25MB"/>
                 <param name="MaxBackupIndex" value="3"/>
                
                 <layout class="org.apache.log4j.PatternLayout">
                 <param name="ConversionPattern" value="%d %-5p [%c] %m%n"/>
                 </layout>
                 </appender>
                
                 <!-- ============================== -->
                 <!-- Append messages to the console -->
                 <!-- ============================== -->
                
                 <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{ABSOLUTE} %-5p [%c{1}] %m%n"/>
                 </layout>
                 </appender>
                
                 <appender name="JSR77" class="org.apache.log4j.FileAppender">
                 <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
                 <param name="Append" value="false"/>
                 <param name="File" value="${jboss.server.home.dir}/log/jsr77.log"/>
                 <layout class="org.apache.log4j.PatternLayout">
                 <param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%c{1}] %m%n"/>
                 </layout>
                 </appender>
                
                 <!-- ====================== -->
                 <!-- More Appender examples -->
                 <!-- ====================== -->
                
                 <!-- Buffer events and log them asynchronously
                 <appender name="ASYNC" class="org.apache.log4j.AsyncAppender">
                 <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
                 <appender-ref ref="FILEDATE"/>
                 <appender-ref ref="CONSOLE"/>
                 <appender-ref ref="SMTP"/>
                 </appender>
                 -->
                
                 <!-- EMail events to an administrator
                 <appender name="SMTP" class="org.apache.log4j.net.SMTPAppender">
                 <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
                 <param name="Threshold" value="ERROR"/>
                 <param name="To" value="admin@myhost.domain.com"/>
                 <param name="From" value="nobody@myhost.domain.com"/>
                 <param name="Subject" value="JBoss Sever Errors"/>
                 <param name="SMTPHost" value="localhost"/>
                 <param name="BufferSize" value="10"/>
                 <layout class="org.apache.log4j.PatternLayout">
                 <param name="ConversionPattern" value="[%d{ABSOLUTE},%c{1}] %m%n"/>
                 </layout>
                 </appender>
                 -->
                
                 <!-- Syslog events
                 <appender name="SYSLOG" class="org.apache.log4j.net.SyslogAppender">
                 <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
                 <param name="Facility" value="LOCAL7"/>
                 <param name="FacilityPrinting" value="true"/>
                 <param name="SyslogHost" value="localhost"/>
                 </appender>
                 -->
                ---------------------------------------------------------------------------------------------
                
                Can, the lines of the code be explained. By the way, is there any way to upload a file on the
                forum.
                
                I hope, my question is clear.
                
                Please, help in solving the doubt.

                regards


                • 5. Re: JBOSS log rotation
                  jaikiran

                  The log4j configuration file that you posted, creates multiple appenders and then associates the loggers with these appenders. Is there any specific part which you did not understand in that file?

                  • 6. Re: JBOSS log rotation
                    ran_sushmi

                     

                    "jaikiran" wrote:
                    The log4j configuration file that you posted, creates multiple appenders and then associates the loggers with these appenders. Is there any specific part which you did not understand in that file?


                    hi,

                    thanks, for your answer. I guess, the only thing that I could make out clearly were the lines,
                    --------------------------------------------------------------------------------------


                    --------------------------------------------------------------------------------------

                    which say that the contents will not be appended to the server.log file on re-start.

                    But, against the contents of the file that I posted, it would be very helpful if you could just write comments on the side.

                    regards.