/
logback-example.xml
116 lines (98 loc) · 4.59 KB
/
logback-example.xml
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
<configuration>
<!--为了防止进程退出时,内存中的数据丢失,请加上此选项-->
<shutdownHook class="ch.qos.logback.core.hook.DelayingShutdownHook"/>
<appender name="loghubAppender1" class="com.aliyun.openservices.log.logback.LoghubAppender">
<!--必选项-->
<!-- 账号及网络配置 -->
<endpoint></endpoint>
<accessKeyId></accessKeyId>
<accessKeySecret></accessKeySecret>
<!-- sls 项目配置 -->
<project>test-proj</project>
<logStore>store1</logStore>
<!--必选项 (end)-->
<!-- 可选项 -->
<topic>topic1</topic>
<source>source1</source>
<!-- 可选项 详见 '参数说明'-->
<totalSizeInBytes>104857600</totalSizeInBytes>
<maxBlockMs>60000</maxBlockMs>
<ioThreadCount>8</ioThreadCount>
<batchSizeThresholdInBytes>524288</batchSizeThresholdInBytes>
<batchCountThreshold>4096</batchCountThreshold>
<lingerMs>2000</lingerMs>
<retries>10</retries>
<baseRetryBackoffMs>100</baseRetryBackoffMs>
<maxRetryBackoffMs>100</maxRetryBackoffMs>
<filter class="ch.qos.logback.classic.filter.ThresholdFilter"><!-- 打印WARN,ERROR级别的日志 -->
<level>WARN</level>
</filter>
<mdcFields>THREAD_ID,MDC_KEY</mdcFields>
</appender>
<appender name="loghubAppender2" class="com.aliyun.openservices.log.logback.LoghubAppender">
<!--必选项-->
<!-- 账号及网络配置 -->
<endpoint></endpoint>
<accessKeyId></accessKeyId>
<accessKeySecret></accessKeySecret>
<!-- sls 项目配置 -->
<project>test-proj</project>
<logStore>store2</logStore>
<!--必选项 (end)-->
<!-- 可选项,自定义 CredentialsProvider 配置 -->
<!-- <credentialsProviderBuilder class="com.aliyun.openservices.log.logback.example.ExampleCredentialsProviderBuilder">-->
<!-- <accessKeyId>${accessKeyId}</accessKeyId>-->
<!-- <accessKeySecret>${accessKeySecret}</accessKeySecret>-->
<!-- </credentialsProviderBuilder>-->
<!-- 可选项 -->
<topic>topic2</topic>
<source>source2</source>
<!-- 可选项 详见 '参数说明'-->
<totalSizeInBytes>104857600</totalSizeInBytes>
<maxBlockMs>0</maxBlockMs>
<ioThreadCount>8</ioThreadCount>
<batchSizeThresholdInBytes>524288</batchSizeThresholdInBytes>
<batchCountThreshold>4096</batchCountThreshold>
<lingerMs>2000</lingerMs>
<retries>10</retries>
<baseRetryBackoffMs>100</baseRetryBackoffMs>
<maxRetryBackoffMs>50000</maxRetryBackoffMs>
<!-- 可选项 通过配置 encoder 的 pattern 自定义 log 的格式 -->
<encoder>
<pattern>%d %-5level [%thread] %logger{0}: %msg</pattern>
</encoder>
<!-- 可选项 设置时间格式 -->
<timeFormat>yyyy-MM-dd'T'HH:mmZ</timeFormat>
<!-- 可选项 设置时区 -->
<timeZone>Asia/Shanghai</timeZone>
<!-- 可选项 设置是否要添加 Location 字段(日志打印位置),默认为 true -->
<includeLocation>true</includeLocation>
<!-- 可选项 当 encoder 不为空时,是否要包含 message 字段,默认为 true。
Optional Whether to include field message when encoder exists, defaults to true.-->
<includeMessage>true</includeMessage>
<filter class="ch.qos.logback.classic.filter.LevelFilter"><!-- 只打印INFO级别的日志 -->
<level>INFO</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
<!-- in the format of "KEY1,KEY2,KEY3" or "*" to match all keys -->
<mdcFields>THREAD_ID,MDC_KEY</mdcFields>
</appender>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<!-- encoders are assigned the type ch.qos.logback.classic.encoder.PatternLayoutEncoder
by default -->
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger - %msg %X{THREAD_ID} %n</pattern>
</encoder>
</appender>
<!-- 可用来获取StatusManager中的状态 -->
<statusListener class="ch.qos.logback.core.status.OnConsoleStatusListener"/>
<!-- 解决debug模式下循环发送的问题 -->
<logger name="org.apache.http.impl.conn.Wire" level="WARN" />
<root>
<level value="DEBUG"/>
<appender-ref ref="loghubAppender1"/>
<appender-ref ref="loghubAppender2"/>
<appender-ref ref="STDOUT"/>
</root>
</configuration>