logback.xml
8.9 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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<property name="log.path" value="/WMSlog" />
<property name="log.pattern" value="%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n" />
<!--<appender name="ROLLING" class="ch.qos.logback.core.rolling.RollingFileAppender" />-->
<property resource="application-druid.properties" />
<property name="dataSource" value="${spring.datasource.type}" />
<property name="driverClassName" value="${spring.datasource.driverClassName}" />
<property name="url" value="${spring.datasource.druid.master.url}" />
<property name="username" value="${spring.datasource.druid.master.username}" />
<property name="password" value="${spring.datasource.druid.master.password}" />
<!-- 控制台输出 -->
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<charset>UTF-8</charset>
<pattern>${log.pattern}</pattern>
</encoder>
<!--<filter class="ch.qos.logback.classic.filter.LevelFilter">-->
<!--<level>INFO</level>-->
<!--<onMatch>ACCEPT</onMatch>-->
<!--<onMismatch>DENY</onMismatch>-->
<!--</filter>-->
</appender>
<!--
TimeBasedRollingPolicy
SizeBasedTriggeringPolicy
官方文档说明当这2个配置同时存在时存在冲突
http://logback.qos.ch/manual/appenders.html#SizeAndTimeBasedFNATP
官方推荐配置如下:
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
rollover daily
<fileNamePattern>mylog-%d{yyyy-MM-dd}.%i.txt</fileNamePattern>
each file should be at most 100MB, keep 60 days worth of history, but at most 20GB
<maxFileSize>100MB</maxFileSize>
<maxHistory>60</maxHistory>
<totalSizeCap>20GB</totalSizeCap>
</rollingPolicy>
-->
<!-- 系统日志输出 只记录DEBUG级别-->
<appender name="file_debug" class="ch.qos.logback.core.rolling.RollingFileAppender">
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>DEBUG</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>${log.path}/sys-debug/sys-debug.%d{yyyyMMdd}-%i.log</fileNamePattern>
<!-- 文件大小触发重写新文件 -->
<maxFileSize>20MB</maxFileSize>
<!-- 日志最大的历史 30天 -->
<maxHistory>30</maxHistory>
<!--最多10GB-->
<totalSizeCap>20GB</totalSizeCap>
</rollingPolicy>
<encoder>
<pattern>${log.pattern}</pattern>
</encoder>
</appender>
<!-- 系统日志输出 只记录INFO级别-->
<appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender">
<!--<file>${log.path}/sys-info/sys-info.log</file>-->
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>INFO</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<!-- 按天回滚 daily -->
<fileNamePattern>${log.path}/sys-info/sys-info.%d{yyyyMMdd}-%i.log</fileNamePattern>
<!-- 文件大小触发重写新文件 -->
<maxFileSize>20MB</maxFileSize>
<!-- 日志最大的历史 30天 -->
<maxHistory>30</maxHistory>
<!--最多2GB-->
<totalSizeCap>5GB</totalSizeCap>
</rollingPolicy>
<encoder>
<pattern>${log.pattern}</pattern>
</encoder>
<!--<triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
<!– 文件大小触发重写新文件 –>
<maxFileSize>20MB</maxFileSize>
</triggeringPolicy>-->
</appender>
<!-- 系统日志输出 只记录WARN级别-->
<appender name="file_warn" class="ch.qos.logback.core.rolling.RollingFileAppender">
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>WARN</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<!-- 按天回滚 daily -->
<fileNamePattern>${log.path}/sys-warn/sys-warn.%d{yyyyMMdd}-%i.log</fileNamePattern>
<!-- 文件大小触发重写新文件 -->
<maxFileSize>20MB</maxFileSize>
<!-- 日志最大的历史 30天 -->
<maxHistory>30</maxHistory>
<!--最多2GB-->
<totalSizeCap>10GB</totalSizeCap>
</rollingPolicy>
<encoder>
<pattern>${log.pattern}</pattern>
</encoder>
<!--<triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
<!– 文件大小触发重写新文件 –>
<maxFileSize>20MB</maxFileSize>
</triggeringPolicy>-->
</appender>
<!-- 系统日志输出 只记录ERROR级别-->
<appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender">
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>ERROR</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>${log.path}/sys-error/sys-error.%d{yyyyMMdd}-%i.log</fileNamePattern>
<!-- 文件大小触发重写新文件 -->
<maxFileSize>20MB</maxFileSize>
<!-- 日志最大的历史 30天 -->
<maxHistory>30</maxHistory>
<!--最多2GB-->
<totalSizeCap>5GB</totalSizeCap>
</rollingPolicy>
<encoder>
<pattern>${log.pattern}</pattern>
</encoder>
<!--<triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
<!– 文件大小触发重写新文件 –>
<maxFileSize>20MB</maxFileSize>
</triggeringPolicy>-->
</appender>
<appender name="erp" class="ch.qos.logback.core.rolling.RollingFileAppender">
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>${log.path}/erp/confirm.%d{yyyyMMdd}.log</fileNamePattern>
<!-- 文件大小触发重写新文件 -->
<!-- 日志最大的历史 30天 -->
<maxHistory>30</maxHistory>
<!--最多2GB-->
</rollingPolicy>
<encoder>
<pattern>${log.pattern}</pattern>
</encoder>
<triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
<maxFileSize>20MB</maxFileSize>
</triggeringPolicy>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>INFO</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<!--将日志传到数据库 表logging_event-->
<appender name="DB" class="ch.qos.logback.classic.db.DBAppender">
<connectionSource class="ch.qos.logback.core.db.DataSourceConnectionSource">
<dataSource class="${dataSource}">
<driverClassName>${driverClassName}</driverClassName>
<url>${url}</url>
<username>${username}</username>
<password>${password}</password>
</dataSource>
</connectionSource>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>ERROR</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<logger name="com.huaheng.api.wcs.service.erpService.ErpServiceImpl" level="info">
<appender-ref ref="erp"></appender-ref>
</logger>
<!-- 显示形成的sql、使用的参数、结果集 -->
<!--<logger name="java.sql" level="DEBUG" >-->
<!--<appender-ref ref="console" />-->
<!--<appender-ref ref="file_info" />-->
<!--</logger>-->
<!--<logger name="org.springframework.jdbc" level="DEBUG">-->
<!--<appender-ref ref="console" />-->
<!--<appender-ref ref="file_info" />-->
<!--</logger>-->
<!--<logger name="com.huaheng" level="debug" />-->
<!--系统操作日志-->
<root level="INFO">
<appender-ref ref="console" />
<appender-ref ref="file_debug"/>
<appender-ref ref="file_info" />
<appender-ref ref="file_warn"/>
<appender-ref ref="file_error"/>
<appender-ref ref="DB"/>
<!--<appender-ref ref="ROLLING" />-->
</root>
<!--系统用户操作日志-->
<!--<logger name="sys-user" level="debug">-->
<!--<appender-ref ref="sys-user"/>-->
<!--</logger>-->
</configuration>