springmvc项目 logback.xml配置 logstash日志收集

配置logback,需要一个转接的Appender,可以通过Maven依赖加到项目中:
<dependency>
<groupId>com.cwbasegroupId> <artifactId>logback-redis-appenderartifactId> <version>1.1.5version> dependency>

 

 
 
配上对应的logback.xml:
xml version="1.0" encoding="UTF-8"?>
<configuration>  <appender name="LOGSTASH_test" class="com.cwbase.logback.RedisAppender"> <source>mysourcesource> <sourcePath>private-rest-sourcePath-movitsourcePath> <type>logtype> <tags>private-rest-movittags> <host>172.18.50.85host> <port>6379port> <key>private-rest-log-mybidkey> appender>  <appender name="ASYNC_test" class="ch.qos.logback.classic.AsyncAppender"> <appender-ref ref="LOGSTASH_test" /> appender> <logger name="xxx.xxx.xxx.xxx" level="info"> <appender-ref ref="ASYNC_test" /> logger> configuration>

 

 
每一个配置项可以参考项目的说明 https://github.com/kmtong/logback-redis-appender
简单的 Logstash Input 配置: http://www.logstash.net/docs/1.4.2/inputs/redis
 
Logstash 配置:

input {
    redis {
        data_type => "list"
        key => "my_log"
        host => "10.0.2.81"
        port => 6379
        batch_count => 1
        threads => 5
    }
}

 

 
可以将logstash收集数据ouput到elasticsearch中,便于查询,
下一篇中将叙述elasticsearch查询logstash中收集的日志

转载于:https://www.cnblogs.com/7motor28/p/9514483.html

你可能感兴趣的:(springmvc项目 logback.xml配置 logstash日志收集)