5 Replies Latest reply on Dec 11, 2017 11:53 AM by jamezp

    Wildfly 10, Log rotation every 10 minutes

    proque_cu

      Hi Team,

       

      Do you happen to have an example code about how to rotate the server.log file every 10 minutes via standalone.xml parameters?

       

      Thanks!!

        • 1. Re: Wildfly 10, Log rotation every 10 minutes
          jamezp

          You'd have to write a custom-handler if you want it to rotate every 10 minutes. The periodic-rotating-file-handler will only rotate on a given segment. For example you can rotate every hour or every minute, but not every 10 minutes.

           

          --

          James R. Perkins

          • 2. Re: Wildfly 10, Log rotation every 10 minutes
            proque_cu

            Hi James,

            That is what we are trying to achieve. We are able to do the 1 minute one but unsure of how to make it work for 10.

            Thx,

            • 3. Re: Wildfly 10, Log rotation every 10 minutes
              jamezp

              The only way would be to write a custom handler.

               

              --

              James R. Perkins

              • 4. Re: Wildfly 10, Log rotation every 10 minutes
                brettking

                Hi James,

                 

                I have the exact same problem described here.  Have a need to rotate the log every 15 minutes on Wildfly 10.1.0 Final, and I've been trying to figure it out.  And we automate the deployments so looking to have it defined within standalone.xml if possible.

                Like above, found a way to log every hour by adding '_HH' to the suffix value, and every minute using '_HH-mm' to the suffix value to a periodic handler, like so:

                 

                            <periodic-rotating-file-handler name="FILE" autoflush="true">

                                <formatter>

                                    <named-formatter name="PATTERN"/>

                                </formatter>

                                <file relative-to="jboss.server.log.dir" path="wildfly_server.log"/>

                                <suffix value=".yyyy-MM-dd_HH-mm"/>

                                <append value="true"/>

                            </periodic-rotating-file-handler>

                 

                 

                I've never used a custom handler before, however it seems like it takes in certain attributes, such as the ones listed here:

                https://wildscribe.github.io/WildFly/10.1/subsystem/logging/custom-handler/index.html

                 

                 

                Below is how I'd envision a custom-handler, using other handlers as a guideline. Also wanted to add in periodic-size type of parameters to remove older logs.

                Can you advise on what needs to be adjusted to have it rotate in 15 minute intervals?  Or am I off the mark and it's controlled somewhere else?

                 

                            <custom-handler name="FILE" autoflush="true">

                                <formatter>

                                    <named-formatter name="PATTERN"/>

                                </formatter>

                                <file relative-to="jboss.server.log.dir" path="wildfly_server.log"/>

                                <suffix value=".yyyy-MM-dd_HH-mm"/>

                                <append value="true"/>

                                <maxBackupIndex value="40"/>

                                <rotateSize value="500m"/>

                            </custom-handler>

                • 5. Re: Wildfly 10, Log rotation every 10 minutes
                  jamezp

                  Hi Brett,

                  You'd have to actually write a custom handler. Currently the jboss-logmanager does not have a handler that will allow a file to be rotated at a specified time.

                   

                  --

                  James R. Perkins