1.依赖
<dependency> <groupId>net.logstash.logback</groupId> <artifactId>logstash-logback-encoder</artifactId> <version>4.9</version> </dependency>
2.配置
<appender name="LOGSTASH" class="net.logstash.logback.appender.LogstashTcpSocketAppender"> <destination>127.0.0.1:4560</destination> <encoder charset="UTF-8" class="net.logstash.logback.encoder.LogstashEncoder" /> </appender> <root level="debug"> <appender-ref ref="console" /> <appender-ref ref="LOGSTASH" /> </root>
3.Logstash配置
input { tcp { port => 4560 codec => json_lines } } output{ elasticsearch { hosts => ["localhost:9200"] } stdout { codec => rubydebug } }
4.kibana添加索引
Management->Create Index Pattern->输入logstash*