logback-spring.xml
3.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<?xml version="1.0" encoding="UTF-8"?>
<configuration debug="false">
<!-- 监听器,指定日志文件存放目录 -->
<contextListener class="org.jeecg.utils.listener.CustomLogContextListener" />
<!--定义日志文件的存储地址 -->
<property name="LOG_HOME" value="${LOG_PATH}/logs" />
<springProperty name="appName" scope="context" source="spring.application.name" />
<!-- 控制台输出 -->
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符 <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50}:%L
- %msg%n</pattern> -->
<pattern>[%-5level] %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %logger:%L - %msg%n</pattern>
<charset class="java.nio.charset.Charset">UTF-8</charset>
</encoder>
</appender>
<!-- 按照每天生成日志文件 -->
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<!--日志文件输出的文件名 -->
<FileNamePattern>${LOG_HOME}/${appName}.%d{yyyy-MM-dd}.%i.log</FileNamePattern>
<!--日志文件保留天数 -->
<MaxHistory>30</MaxHistory>
<maxFileSize>100MB</maxFileSize>
<totalSizeCap>10GB</totalSizeCap>
<cleanHistoryOnStart>true</cleanHistoryOnStart>
</rollingPolicy>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符 -->
<pattern>[%-5level] %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %logger{50}:%L - %msg%n</pattern>
<charset class="java.nio.charset.Charset">UTF-8</charset>
</encoder>
</appender>
<!--myibatis log configure -->
<!-- <logger name="com.apache.ibatis" level="TRACE" /> -->
<!-- <logger name="java.sql.Connection" level="DEBUG" /> -->
<!-- <logger name="java.sql.Statement" level="DEBUG" /> -->
<!-- <logger name="java.sql.PreparedStatement" level="DEBUG" /> -->
<logger name="jdbc.connection" additivity="false" level="off">
<appender-ref ref="STDOUT" />
<appender-ref ref="FILE" />
</logger>
<logger name="jdbc.resultsettable" additivity="false" level="info" >
<appender-ref ref="STDOUT" />
<appender-ref ref="FILE" />
</logger>
<logger name="jdbc.resultset" additivity="false" level="off">
<appender-ref ref="STDOUT" />
<appender-ref ref="FILE" />
</logger>
<logger name="jdbc.audit" additivity="false" level="off">
<appender-ref ref="STDOUT" />
<appender-ref ref="FILE" />
</logger>
<logger name="jdbc.sqlonly" additivity="false" level="off">
<appender-ref ref="STDOUT" />
<appender-ref ref="FILE" />
</logger>
<logger name="jdbc.sqltiming" additivity="false" level="info">
<appender-ref ref="STDOUT" />
<appender-ref ref="FILE" />
</logger>
<!-- 日志输出级别 -->
<root level="INFO">
<appender-ref ref="STDOUT" />
<appender-ref ref="FILE" />
<!-- <appender-ref ref="HTML" /> -->
<!-- <appender-ref ref="FILE_HTML" /> -->
</root>
</configuration>