如何将调度程序日志写入注释日志文件?

时间:2018-06-27 12:28:23

标签: java logging

我有此日志配置

<?xml version="1.0" encoding="UTF-8"?>

<configuration>

  <include resource="org/springframework/boot/logging/logback/base.xml"/>

  <appender name="ROLLING" class="ch.qos.logback.core.rolling.RollingFileAppender">
    <file>logs/server.log</file>
    <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
      <FileNamePattern>logs/history/log-%d{dd.MM.yyyy}.%i.log.zip</FileNamePattern>
      <maxFileSize>50MB</maxFileSize>
      <maxHistory>60</maxHistory>
      <totalSizeCap>20GB</totalSizeCap>
    </rollingPolicy>
    <encoder>
      <pattern># [%d{dd.MM.yyyy HH:mm:ss.SSS}] [%-5level] [%thread] [%lo.%method] [%msg]%n</pattern>
    </encoder>
  </appender>

  <springProfile name="local">
    <root level="INFO">
      <appender-ref ref="CONSOLE"/>
      <!--<appender-ref ref="ROLLING"/>-->
    </root>
  </springProfile>
  <springProfile name="prod">
    <root level="INFO">
      <appender-ref ref="CONSOLE"/>
      <appender-ref ref="ROLLING"/>
    </root>
  </springProfile>

</configuration>

现在,我要写入调度程序日志到另一个日志文件,因为它每5秒写入一次日志并污染日志。而且我也不想禁用Scheduler日志,因为我必须看到它能正常工作。

log.info("There are: {} notifications", userNotifications.size());

如何将该信息记录到另一个日志文件中?

0 个答案:

没有答案