zoukankan      html  css  js  c++  java
  • 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" /> -->
            <!-- 日志输出编码 -->
            <encoder class="net.logstash.logback.encoder.LoggingEventCompositeJsonEncoder">
                <providers>
                    <timestamp>
                        <timeZone>UTC</timeZone>
                    </timestamp>
                    <pattern>
                        <pattern>
                            {
                            "severity": "%level",
                            "service": "${springAppName:-}",
                            "trace": "%X{X-B3-TraceId:-}",
                            "span": "%X{X-B3-SpanId:-}",
                            "exportable": "%X{X-Span-Export:-}",
                            "pid": "${PID:-}",
                            "thread": "%thread",
                            "class": "%logger{40}",
                            "msg": "%message"
                            }
                        </pattern>
                    </pattern>
                </providers>
            </encoder>
        </appender>

    3.Logstash配置

    input {
        tcp {
            port => 4560
            codec => json_lines
        }
    }
    output{
      elasticsearch { hosts => ["localhost:9200"] }
      stdout { codec => rubydebug }
    }
    另:插件安装/logstash-plugin install logstash-codec-json_lines

    4.kibana添加索引

    Management->Create Index Pattern->输入logstash*

  • 相关阅读:
    datagridview 保存为excel输出
    将excel导入到datatable
    Json 转换为c#数组
    css 没有图片则隐藏或者显示默认图片
    模拟Get请求
    根据多个字符分隔字符串
    DbHelperSQL
    数据库相关
    json对象
    ajax滚动条懒加载
  • 原文地址:https://www.cnblogs.com/wujf/p/11082791.html
Copyright © 2011-2022 走看看