⽇志配置⽂件l
项⽬⾥l配置了⽇志输出路径,使⽤⽅法为:
private static final Logger LOG = Logger("log");
private static final Logger COUNT_LOG = Logger("count");
log4j2自定义日志文件名<?xml version='1.0' encoding='utf-8' ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j="/log4j/">
<appender name="console" class="org.apache.log4j.ConsoleAppender">
<layout class="org.apache.log4j.PatternLayout">
<!-- param name="ConversionPattern" value="%d{yyyy-MM-dd HH:mm:ss.SSS} %t %5p [%c:%L] - %m%n" /> --> <param name="ConversionPattern" value="%m%n"/>
</layout>
</appender>
<appender name="FILE-LOG" class="org.apache.log4j.RollingFileAppender">
<!-- 设置⽇志输出⽂件名 -->
<param name="File" value="/export/admin/stat/log.log"/>
<param name="Append" value="true"/>
<param name="encoding" value="UTF-8"/>
<param name="MaxFileSize" value="800MB"/>
<param name="MaxBackupIndex" value="100"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%m%n"/>
</layout>
</appender>
<category name="log" additivity="false">
<priority value="DEBUG"/>
<appender-ref ref="console"/>
<appender-ref ref="FILE-LOG"/>
</category>
<appender name="FILE-COUNT" class="org.apache.log4j.RollingFileAppender">
<!-- 设置⽇志输出⽂件名 -->
<param name="File" value="/export/admin/stat/count.log"/>
<param name="Append" value="true"/>
<param name="encoding" value="UTF-8"/>
<param name="MaxFileSize" value="800MB"/>
<param name="MaxBackupIndex" value="100"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%m%n"/>
</layout>
</appender>
<category name="count" additivity="false">
<priority value="DEBUG"/>
<appender-ref ref="FILE-COUNT"/>
</category>
<root>
<priority value="warn"/>
<appender-ref ref="console"/>
</root>
</log4j:configuration>

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。