2 Replies Latest reply on Mar 2, 2016 11:38 AM by hchenkwi

    Wildfly 9 how to use rotate-on-boot?

    hchenkwi

      Hi,

       

      I'm using Wildfly 9.0.2 final version.  I'm trying to set up logging using rotate-on-boot property, so everytime the Wildfly is shutdown and brought up, the log file rotate.

       

      What I want is:

      1. the log file rotate everyday 

      2. the log file rotate whenever Wildfly get restarted.

       

      But it doesn't seem that the server.log file get rotated when I shutdown and bring up Wildfly.  Can anyone tell me how to make it work?

       

      The following is what I added:

              <custom-handler name="FILE" class="org.jboss.logmanager.handlers.PeriodicSizeRotatingFileHandler" module="org.jboss.logmanager">

                  <level name="DEBUG"/>

                  <formatter>

                          <named-formatter name="PATTERN"/>

                  </formatter>

                  <properties>

                      <property name="autoFlush" value="true"/>

                      <property name="append" value="true"/>

                      <property name="suffix" value=".yyyy-MM-dd"/>

                      <property name="fileName" value="${jboss.server.log.dir}/server.log"/>

                      <property name="rotateOnBoot" value="true"/>

                      <property name="maxBackupIndex" value="10"/>

                      <property name="rotateSize" value="1099511627776"/>

                  </properties>

              </custom-handler>

                  <root-logger>

                      <level name="DEBUG"/>

                      <handlers>

                          <handler name="CONSOLE"/>

                          <handler name="FILE"/>

                      </handlers>

                  </root-logger>

       

      Thanks, Helen

        • 1. Re: Wildfly 9 how to use rotate-on-boot?
          jaysensharma

          Hello Helen,

           

          One option that i can think of will be to pass the server.log file name dynamically based on the timestamp as following:


          1. Edit the standalone.xml (Or your profile file)  file and then edit it as following:  <file relative-to="jboss.server.log.dir" path="${server.log.dynamic.name}"/>


          <periodic-rotating-file-handler name="FILE" autoflush="true">
              <formatter>
                  <named-formatter name="PATTERN"/>
              </formatter>
              <!-- <file relative-to="jboss.server.log.dir" path="server.log"/> -->
              <file relative-to="jboss.server.log.dir" path="${server.log.dynamic.name}"/>    <!-- NOTICE !!! -->
              <suffix value=".yyyy-MM-dd"/>
              <append value="true"/>
          </periodic-rotating-file-handler>
          
          

           

           

          2. Now start the WildFly by passing the dynamic file name:

          ./standalone.sh -c standalone.xml -Dserver.log.dynamic.name=server_`date +%Y%m%d-%H%M`.log
          
          

           

           

           

          In your case you can try doing the same thing with your "custom-handler"   As following:

           <property name="fileName" value="${jboss.server.log.dir}/${server.log.dynamic.name}"/>
          

          Regards

          Jay SenSharma

          • 2. Re: Wildfly 9 how to use rotate-on-boot?
            hchenkwi

            Hi Jay,

             

            Your solution is actually specifying the log file name at startup script.

             

            Then what does  the rotate-on-boot flag mean? I thought it will rotate the log file automatically. Maybe my understanding for this flag is wrong.

             

            Thanks a lot for your help,

             

            Helen