【问题标题】:How to rotate log file in jboss 6 AS如何在 jboss 6 AS 中旋转日志文件
【发布时间】:2014-01-26 08:40:22
【问题描述】:

在我的 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>

请帮帮我

【问题讨论】:

    标签: logging jboss6.x log-rotation


    【解决方案1】:

    要每天使用一个文件保留 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>
    

    【讨论】:

    • 感谢回复我试试
    【解决方案2】:

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-08-09
      • 1970-01-01
      • 2023-03-03
      • 1970-01-01
      • 2021-06-04
      • 2014-11-19
      • 1970-01-01
      相关资源
      最近更新 更多