How to rotate log file in jboss 6 AS

Indra Yadav picture Indra Yadav · Jan 8, 2014 · Viewed 7.2k times · Source

In my jboss 6.1.0 final AS i want to keep 30 days log..

in jboss-logging.xml there is size-rotating-file-handler which i don't want.. i need to rotate log file every day.. how can change the log configuration

my logging configuration is -

<periodic-rotating-file-handler
     file-name="${jboss.server.log.dir}/server.log"
     name="FILE"
     autoflush="true"
     append="true"
     suffix="..yyyy-MM-dd">  <!-- To roll over at the top of each hour, use ".yyyy-MM-dd-HH" instead -->

  <error-manager>
     <only-once/>
  </error-manager>

  <formatter>
     <!-- To revert back to simple stack traces without JAR versions, change "%E" to "%e" below. -->
     <!-- Uncomment this to get the class name in the log as well as the category
     <pattern-formatter pattern="%d %-5p [%c] %C{1} (%t) %s%E%n"/>
     -->
     <!-- Uncomment this to log without the class name in the log -->
     <pattern-formatter pattern="%d %-5p [%c] (%t) %s%E%n"/>
  </formatter>

please help me

Answer

DaveB picture DaveB · Jan 19, 2014

To keep 30 days of logs with one file for each day try the following...

<periodic-rotating-file-handler
     file-name="${jboss.server.log.dir}/server.log"
     name="FILE"
     autoflush="true"
     append="true"
     suffix=".dd">  <!-- To roll over at the top of each hour, use ".yyyy-MM-dd-HH" instead -->

  <error-manager>
     <only-once/>
  </error-manager>

  <formatter>
     <!-- To revert back to simple stack traces without JAR versions, change "%E" to "%e" below. -->
     <!-- Uncomment this to get the class name in the log as well as the category
     <pattern-formatter pattern="%d %-5p [%c] %C{1} (%t) %s%E%n"/>
     -->
     <!-- Uncomment this to log without the class name in the log -->
     <pattern-formatter pattern="%d %-5p [%c] (%t) %s%e%n"/>
  </formatter>
</periodic-rotating-file-handler>