1. 解決方案
- 異步logger,還需要在pom.xml中添加disruptor的依賴;
- includeLocation結合異步logger使用,當其設置為true時,才會顯示具體的行號,以及日志所在的類名;
- 如果設置為false,哪怕<Pattern>設置了輸出行號也不會顯示出來;
2. pom配置
<dependency> <groupId>com.lmax</groupId> <artifactId>disruptor</artifactId> <version>3.3.6</version> </dependency>
3. 屬性配置
設置 AsyncRoot 的 includeLocation 屬性為 true;
xml 格式示例:
<AsyncRoot level="info" includeLocation="true"> <AppenderRef ref="File"/> </AsyncRoot>
yaml 格式示例:
Loggers:
AsyncRoot:
level: info
includeLocation: true
AppenderRef:
- ref: console
- ref: running_log
