码迷,mamicode.com
首页 > 其他好文 > 详细

Logback与Logstash的使用

时间:2017-05-23 21:45:46      阅读:240      评论:0      收藏:0      [点我收藏+]

标签:logstash.logback   redis.elk   

       通过Redis以JSON格式把Log发布到Logstash里

  1. Maven的配置

  2. <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

Logback与Logstash的使用

标签:logstash.logback   redis.elk   

原文地址:http://59465168.blog.51cto.com/5268021/1928687

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!