如何将wildfly server.log配置为具有固定大小并每天轮换并仅保留日志5天

问题描述

standalone.xml中的代码

**以下配置未产生结果。

<file relative-to="jboss.server.log" path="server.log"/>
<suffix value=".yyyy-MM-dd"/>
<rotate-size value="500m"/>
<append value="true"/>
<max-backup-index value="5"/>

解决方法

使用periodic-size-rotating-file-handler属性时,suffix不会清除备份。请参见Wildscribe documentation。已经要求这样做,但是实际上并没有确定要清除哪些文件的好方法。

,

您可能需要直接在standalone.xml内部使用旋转文件处理程序,如下所示:

<profile>
  <subsystem xmlns="urn:jboss:domain:logging:3.0">    
    <periodic-rotating-file-handler name="FILE" autoflush="true">
      <formatter>
        <named-formatter name="PATTERN"/>
      </formatter>
      <file relative-to="jboss.server.log.dir" path="server.log"/>
      <suffix value=".yyyy-MM-dd"/>
      <append value="true"/>
    </periodic-rotating-file-handler>
  </subsystem>
</profile>