我在Spring Boot应用程序中使用Docker ELK堆栈。所有三个组件分别在http://192.168.99.100:5601/,http://192.168.99.100:9200/和192.168.99.100:5000处启动并运行。
我的logback-spring.xml如下所示:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<include resource="org/springframework/boot/logging/logback/base.xml"/>
<appender name="stash" class="net.logstash.logback.appender.LogstashTcpSocketAppender">
<keepAliveDuration>5 minutes</keepAliveDuration>
<reconnectionDelay>10 second</reconnectionDelay>
<waitStrategyType>sleeping</waitStrategyType>
<destination>192.168.99.100:5000</destination>
<encoder class="net.logstash.logback.encoder.LoggingEventCompositeJsonEncoder">
<providers>
<mdc/> <!-- MDC variables on the Thread will be written as JSON fields-->
<context/> <!--Outputs entries from logback's context -->
<logLevel/>
<loggerName/>
<pattern>
{
"timestamp": "%date{\"yyyy-MM-dd'T'HH:mm:ss,SSSXXX\", UTC}",
"level": "%level",
"logger": "%logger",
"message": "%message",
"logstashMarkers": "%marker"
}
</pattern>
<threadName/>
<message/>
<logstashMarkers/> <!-- Useful so we can add extra information for specific log lines as Markers-->
<arguments/> <!--or through StructuredArguments-->
<stackTrace>
<fieldName>stackTrace</fieldName>
<throwableConverter class="net.logstash.logback.stacktrace.ShortenedThrowableConverter">
<exclude>net\.sf\.cglib\..*</exclude>
<maxDepthPerThrowable>30</maxDepthPerThrowable>
<rootCauseFirst>true</rootCauseFirst>
</throwableConverter>
</stackTrace>
</providers>
</encoder>
</appender>
<root level="INFO">
<appender-ref ref="stash"/>
</root>
问题是我无法在Kibana中看到我的日志,我怀疑LogstashTcpSocketAppender是不是将日志发送到Logstash。有没有办法验证LogstashTcpSocketAppender是否正在向Logstash发送日志?