logback-spring.xml
3.23 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
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<!-- 日志名称 -->
<property name="LOG_NAME" value="uap-boot" />
<!--定义日志文件的存储地址 勿在 LogBack 的配置中使用相对路径 -->
<property name="LOG_HOME" value="logs" />
<!-- springProperty读取springboot配置属性 -->
<springProperty scope="context" name="build.profile.id" source="spring.profiles.active" />
<statusListener class="ch.qos.logback.core.status.NopStatusListener" />
<!-- 日志控制台输出 -->
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d %-5level [${LOG_NAME}-${build.profile.id}] [%t] [%c:%L] -| %msg%n</pattern>
</encoder>
</appender>
<!-- 日志文件输出 -->
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${LOG_HOME}/${LOG_NAME}.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<!--日志文件输出的文件名 -->
<fileNamePattern>${LOG_HOME}/%d{yyyy-MM-dd}/${LOG_NAME}_%i.log.zip</fileNamePattern>
<!--日志文件保留天数(FileNamePattern中的%d 格式有关,如果yyyy-MM-dd 则是天数) -->
<maxHistory>10</maxHistory>
<!--日志文件最大的大小 -->
<maxFileSize>10MB</maxFileSize>
</rollingPolicy>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>%d %-5level [${LOG_NAME}-${build.profile.id}] [%t] [%c:%L]-| %msg%n</pattern>
</encoder>
</appender>
<!-- 开发环境 -->
<springProfile name="dev">
<root level="INFO">
<appender-ref ref="CONSOLE" />
</root>
<logger name="com.diligrp.assistant" level="DEBUG" additivity="false">
<appender-ref ref="CONSOLE" />
</logger>
<logger name="com.alibaba" level="ERROR" additivity="false">
<appender-ref ref="CONSOLE" />
</logger>
</springProfile>
<!-- 测试环境 -->
<springProfile name="test">
<root level="INFO">
<appender-ref ref="CONSOLE" />
</root>
<logger name="com.diligrp.assistant" level="DEBUG">
<appender-ref ref="FILE" />
</logger>
<logger name="com.alibaba" level="ERROR" additivity="false">
<appender-ref ref="CONSOLE" />
<appender-ref ref="FILE" />
</logger>
</springProfile>
<!-- 灰度、生产环境 -->
<springProfile name="pre,prod">
<root level="INFO">
<appender-ref ref="CONSOLE" />
</root>
<logger name="com.diligrp.assistant" level="DEBUG">
<appender-ref ref="FILE" />
</logger>
<logger name="com.alibaba" level="ERROR" additivity="false">
<appender-ref ref="CONSOLE" />
<appender-ref ref="FILE" />
</logger>
<!-- 单独给子模块指定日志配置时,请注意additivity的使用
<logger name="com.diligrp.assistant.boss" level="debug" additivity="false">
<appender-ref ref="CONSOLE" />
<appender-ref ref="FILE" />
</logger>
-->
</springProfile>
</configuration>