Files
ClassroomInteraction/Teacher/src/main/resources/log4j2.xml

36 lines
1.6 KiB
XML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?xml version="1.0" encoding="UTF-8"?>
<Configuration>
<Properties>
<!-- 定义日志格式 -->
<Property name="log.pattern">[%d{DEFAULT}] [%t/%-5level] %logger{36}: %msg%n</Property>
<!-- 定义文件名变量 -->
<Property name="file.info.filename">logs/latest21.log</Property>
<Property name="file.info.pattern">logs/%d{yyyy-MM-dd}-%i.log.gz</Property>
</Properties>
<!-- 定义Appender即目的地 -->
<Appenders>
<!-- 定义输出到屏幕 -->
<Console name="console" target="SYSTEM_OUT">
<!-- 日志格式引用上面定义的log.pattern -->
<PatternLayout pattern="${log.pattern}" />
</Console>
<!-- 定义输出到文件,文件名引用上面定义的file.info.filename -->
<RollingFile name="file" bufferedIO="true" fileName="${file.info.filename}" filePattern="${file.info.pattern}">
<PatternLayout pattern="${log.pattern}" />
<Policies>
<!-- 根据文件大小自动切割日志 -->
<SizeBasedTriggeringPolicy size="1 MB" />
</Policies>
<!-- 保留最近10份 -->
<DefaultRolloverStrategy max="10" />
</RollingFile>
</Appenders>
<Loggers>
<Root level="all">
<!-- 对info级别的日志输出到console -->
<AppenderRef ref="console" level="all" />
<!-- 对info级别的日志输出到file即上面定义的RollingFile -->
<AppenderRef ref="file" level="all" />
</Root>
</Loggers>
</Configuration>