通过Redis以JSON格式把Log发布到Logstash里
Maven的配置
<dependency> <groupId>com.cwbase</groupId> <artifactId>logback-redis-appender</artifactId> <version>1.1.5</version> </dependency>
2.logback-spring.xml配置
(1)同步方式 <appender name="LOGSTASH" class="com.cwbase.logback.RedisAppender"> <source>mySource</source> <!--自定义的--> <sourcePath>mySourcePath</sourcePath> <!--自定义的--> <type>my</type> <!--自定义的,便于区分不同的日志--> <tags>prod</tags> <host>192.168.16.20</host> <port>6379</port> <key>logstash</key> </appender> (2)异步方式 <configuration> <appender name="LOGSTASH" class="com.cwbase.logback.RedisAppender"> <source>mySource</source> <sourcePath>mySourcePath</sourcePath> <type>my</type> <tags>prod</tags> <host>192.168.16.20</host> <port>6379</port> <key>logstash</key> </appender> <appender name="ASYNC" class="ch.qos.logback.classic.AsyncAppender"> <appender-ref ref="LOGSTASH" /> </appender> <root level="DEBUG"> <appender-ref ref="ASYNC" /> </root> </configuration>
3.Logstash配置
input { redis { codec => json host => "192.168.16.20" port => 6379 key => "logstash" data_type => "list" } }
问题:Redis的保护模式修改:
config set protected-mode no
本文出自 “Apple” 博客,请务必保留此出处http://59465168.blog.51cto.com/5268021/1928687
原文地址:http://59465168.blog.51cto.com/5268021/1928687