-
pom文件添加
spring boot 项目配置添加
<!-- logstash -->
<dependency>
<groupId>net.logstash.logback</groupId>
<artifactId>logstash-logback-encoder</artifactId>
<version>4.11</version>
</dependency>
<dependency>
<groupId>net.logstash.log4j</groupId>
<artifactId>jsonevent-layout</artifactId>
<version>1.7</version>
</dependency>
-
logback 添加配置
<appender name="stash"
class="net.logstash.logback.appender.LogstashTcpSocketAppender">
<destination>119.2.113.111:9100</destination>
<encoder class="net.logstash.logback.encoder.LogstashEncoder" />
</appender>
<root level="Info">
<appender-ref ref="STDOUT" />
<appender-ref ref="stash"/>
</root>
注意 因为logstash 里面 配置是json 所以我们最好打印json日志发送过去
网友评论