日志收集

引入包

<dependency>

    <groupId>net.logstash.logback</groupId>

     <artifactId>logstash-logback-encoder</artifactId>

     <version>4.4</version>

</dependency>


在日志中加入如下代码

<appender name="stash"class="net.logstash.logback.appender.LogstashTcpSocketAppender">

     <remoteHost>192.168.20.50</remoteHost>

     <port>5514</port>

     <!-- encoder is required -->

     <encoder class="net.logstash.logback.encoder.LogstashEncoder" />

</appender>


<root level="INFO">

         <appender-ref ref="stash" />

        <appender-ref ref="stdout" />

</root>

logback简单的配置

input {

  syslog {

    type => "xlbstudy"

    port => 5514

    codec => "json"

  }

}

output {

  elasticsearch { hosts => ["localhost:9200"] }

  stdout { codec => rubydebug }

}

这样子就能收集日志到append里面去了

你可能感兴趣的:(日志收集)