logback TimeBasedRollingPolicy中的多个%d说明符的maxHistory

时间:2016-10-18 02:32:09

标签: java logback

在logback xml中

<appender name="REQUEST_APPENDER" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${REQUEST_LOG_DIR}/request_${server.ip}_${server.port}.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
  <!-- minute rollover -->
  <fileNamePattern>${REQUEST_LOG_DIR}/request_archives/%d{yyyy-MM-dd,aux}/ip_${server.ip}/port_${server.port}/request_%d{yyyy-MM-dd_HH-mm}.log</fileNamePattern>
  <!-- 24 * 7 * 60, keep last 7 days history -->
  <maxHistory>10080</maxHistory>
</rollingPolicy>
<encoder>
  <pattern>%msg%n</pattern>
</encoder>

我想保留7天的日志,但它不起作用。我尝试以下操作,但仍无效:

<!-- minute rollover -->
  <fileNamePattern>${REQUEST_LOG_DIR}/request_archives/%d{yyyy-MM-dd}/ip_${server.ip}/port_${server.port}/request_%d{yyyy-MM-dd_HH-mm,aux}.log</fileNamePattern>
  <!-- keep last 7 days history -->
  <maxHistory>7</maxHistory>

0 个答案:

没有答案