springboot日志输出到logstash,logstash端没有日志输出,为什么? 5
按照网上的配置,都配上了。可就是没有输出,项目结构如图所示:logback-spring.xml的内容如下:<?xmlversion="1.0"encoding="UTF...
按照网上的配置,都配上了。可就是没有输出,项目结构如图所示:
logback-spring.xml的内容如下:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<include resource="org/springframework/boot/logging/logback/base.xml" />
<appender name="LOGSTASH" class="net.logstash.logback.appender.LogstashTcpSocketAppender">
<destination>x.x.x.x:4560</destination>
<!-- 日志输出编码 -->
<encoder charset="UTF-8"
class="net.logstash.logback.encoder.LoggingEventCompositeJsonEncoder">
<providers>
<timestamp>
<timeZone>UTC</timeZone>
</timestamp>
<pattern>
<pattern>
{
"logLevel": "%level",
"serviceName": "${springAppName:-}",
"pid": "${PID:-}",
"thread": "%thread",
"class": "%logger{40}",
"rest": "%message"
}
</pattern>
</pattern>
</providers>
</encoder>
</appender>
<root level="INFO">
<appender-ref ref="LOGSTASH" />
<appender-ref ref="CONSOLE" />
</root>
</configuration>
java文件中也是引用的
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
这个包下的
private static final Logger LOGGER=LoggerFactory.getLogger(DemoApplication.class);
现在控制台有日志输出,logstash控制台没有输出,这是为什么啊? 展开
logback-spring.xml的内容如下:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<include resource="org/springframework/boot/logging/logback/base.xml" />
<appender name="LOGSTASH" class="net.logstash.logback.appender.LogstashTcpSocketAppender">
<destination>x.x.x.x:4560</destination>
<!-- 日志输出编码 -->
<encoder charset="UTF-8"
class="net.logstash.logback.encoder.LoggingEventCompositeJsonEncoder">
<providers>
<timestamp>
<timeZone>UTC</timeZone>
</timestamp>
<pattern>
<pattern>
{
"logLevel": "%level",
"serviceName": "${springAppName:-}",
"pid": "${PID:-}",
"thread": "%thread",
"class": "%logger{40}",
"rest": "%message"
}
</pattern>
</pattern>
</providers>
</encoder>
</appender>
<root level="INFO">
<appender-ref ref="LOGSTASH" />
<appender-ref ref="CONSOLE" />
</root>
</configuration>
java文件中也是引用的
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
这个包下的
private static final Logger LOGGER=LoggerFactory.getLogger(DemoApplication.class);
现在控制台有日志输出,logstash控制台没有输出,这是为什么啊? 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询