2

在我的 jboss 6.1.0 最终版中,我想保留 30 天的日志..

在 jboss-logging.xml 中有我不想要的 size-rotating-file-handler ..我需要每天轮换日志文件..如何更改日志配置

我的日志记录配置是 -

<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>

请帮我

4

2 回答 2

2

要每天使用一个文件保留 30 天的日志,请尝试以下操作...

<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>
于 2014-01-19T00:21:58.633 回答
0

要了解后缀参数,您必须查看PeriodicRotatingFileHandler.java的来源并想知道。

setSuffix 遍历 suffix 的字符,为每个字符创建一个 Period 对象,并取最后一个。因此,如果后缀以 m 结尾,则采用 Period.MINUTE。

于 2016-06-17T08:51:09.633 回答