logback整合Logstash

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*

上一篇:更换ubuntu apt-get 源


下一篇:解决python3.6使用pickle.load()的编码问题:UnicodeDecodeError: 'gbk' codec can't decode byte 0x8