我想达到的目标:
我尝试了什么:
<dependency>
<groupId>net.logstash.logback</groupId>
<artifactId>logstash-logback-encoder</artifactId>
<version>7.3</version>
</dependency>
有了这个 logback.xml:
<?xml version="1.0" encoding="UTF-8"?>
<configuration debug="true">
<appender name="LOGSTASH" class="net.logstash.logback.appender.LogstashTcpSocketAppender">
<encoder class="net.logstash.logback.encoder.LogstashEncoder"/>
<destination>the-logstash.com:5000</destination>
</appender>
<root level="INFO">
<appender-ref ref="LOGSTASH"/>
</root>
</configuration>
在 logstash 方面,我使用的是这个配置:
output {
stdout {
codec => rubydebug
}
elasticsearch {
hosts => ["localhost:9200"]
index => theindex
}
}
观察,在索引theindex下可以看到elasticsearch中的日志
问题:
问题:
spring.logstash.index=someotherindex
或直接从 logback.xml?