logback 日志模板
logback 日志模板
在项目的 \src\main\resources 目录下创建 logback.xml 文件并填入如下内容:
<?xml version="1.0" encoding="UTF-8" ?>
<configuration>
<substitutionProperty name="directoryPath" value="/log/platform/" />
<substitutionProperty name="wholeLogFilePath" value="${directoryPath}trade.log" />
<substitutionProperty name="charset" value="UTF-8" />
<appender name="standardOutput" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d %p [%t] %c (%L\) %m%n</pattern>
<charset>${charset}</charset>
</encoder>
</appender>
<appender name="wholeLog" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${wholeLogFilePath}</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>${wholeLogFilePath}_%d.%i</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>100 MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
<encoder>
<pattern>%date %level [%thread] %class (%line\) %m%n</pattern>
<charset>${charset}</charset>
</encoder>
</appender>
<root level="debug">
<appender-ref ref="standardOutput" />
</root>
<logger name="com.zte.iptv" level="debug">
<appender-ref ref="wholeLog" />
</logger>
</configuration>