ELK的搭建我在上一篇博客中介绍过了,如果还不清楚的朋友请移步到上一篇博客
https://blog.csdn.net/m0_38105115/article/details/95591423
把Logstash的conf配置文件改成
input {
tcp {
host => "localhost"
port => 9601
mode => "server"
tags => ["tags"]
##格式json
codec => json_lines
}
}
output {
elasticsearch {
hosts => "127.0.0.1:9200"
index => "%{[appname]}-%{+YYYY.MM.dd}"
}
stdout { codec => rubydebug}
}
然后在Spring Boot中配置日志处理
resources\logback.xml
<?xml version="1.0" encoding="UTF-8"?>
<!--该日志将日志级别不同的log信息保存到不同的文件中 -->
<configuration>
<appender name="LOGSTASH"
class="net.logst