How to rotate log file in jboss 6 AS

7.4k views Asked by At

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

2

There are 2 answers

0
DaveB On

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>
0
weberjn On

To understand the suffix parameter you have to look at the source of PeriodicRotatingFileHandler.java and wonder.

setSuffix iterates over the characters of suffix, creates a Period object for each, and the final one is taken. So, if suffix ends with m, Period.MINUTE is taken.