开源中国 2018 年度最后一场技术盛会邀你来约~错过就要等明年啦!点此立即预约

Genesis / LoggingAppender日志收集插件JavaApache-2.0

指数
0
Watch 45 Star 92 Fork 35
加入码云
与超过 300 万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
收集java日志到Redis或者Kafka中的插件,日志收集完之后可使用ELK栈做分析(暂时只支持Logback) 展开 收起

https://github.com/jxttian/LoggingAppender.git

取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README.md

logging-appender

##logback

-- pom.xml添加依赖

    <dependency>
        <groupId>org.redisson</groupId>
        <artifactId>redisson</artifactId>
        <version>3.2.3</version>
    </dependency>
    <dependency>
        <groupId>org.apache.kafka</groupId>
        <artifactId>kafka-clients</artifactId>
        <version>0.10.1.1</version>
    </dependency>
    <dependency>
        <groupId>net.myscloud.plugin</groupId>
        <artifactId>logging-appender</artifactId>
        <version>1.0-SNAPSHOT</version>
    </dependency>

-- logback.xml添加Appender

    <appender name="Redis" class="net.myscloud.plugin.logging.logback.LogbackAppender">
        <buildStrategy class="net.myscloud.plugin.logging.logback.build.RedisSingleBuildStrategy">
            <config class="net.myscloud.plugin.logging.logback.config.RedisConfig">
                <addresses>127.0.0.1:6379</addresses>
                <topic>redis-log</topic>
            </config>
        </buildStrategy>
        <deliveryStrategy
                class="net.myscloud.plugin.logging.logback.delivery.AsynchronousDeliveryStrategy"/>
        <source>test-application</source>
    </appender>

    <appender name="Kafka" class="net.myscloud.plugin.logging.logback.LogbackAppender">
        <buildStrategy class="net.myscloud.plugin.logging.logback.build.KafkaBuildStrategy">
            <config class="net.myscloud.plugin.logging.logback.config.KafkaConfig">
                <addresses>127.0.0.1:9092</addresses>
                <topic>topic1</topic>
            </config>
        </buildStrategy>
        <deliveryStrategy
                class="net.myscloud.plugin.logging.logback.delivery.AsynchronousDeliveryStrategy"/>
        <source>test-application</source>
    </appender>

-- 日志格式

    {
        "@timestamp": "2017-01-17T10:40:53.129+0800",
        "host": "10.2.85.49",
        "level": "WARN",
        "logger": "net.myscloud.plugin.logging.logback.redis.appender.LogbackRedisAppenderTest",
        "message": "test87",
        "source": "test-application",
        "thread": "main"
    }

-- https://www.elastic.co/guide/en/logstash/current/plugins-inputs-redis.html#plugins-inputs-redis

-- 集成SpringBoot 如果需要把Redis或者Kafka地址配置在SpringBoot配置文件中可使用

    <springProperty scope="context" name="kafkaAddresses" source="logback.kafka.addresses"/>

    <appender name="Kafka" class="net.myscloud.plugin.logging.logback.LogbackAppender">
        <buildStrategy class="net.myscloud.plugin.logging.logback.build.KafkaBuildStrategy">
            <config class="net.myscloud.plugin.logging.logback.config.KafkaConfig">
                <addresses>${kafkaAddresses}</addresses>
                <topic>topic1</topic>
            </config>
        </buildStrategy>
        <deliveryStrategy
                class="net.myscloud.plugin.logging.logback.delivery.AsynchronousDeliveryStrategy"/>
        <source>test-application</source>
    </appender>

项目点评 ( 3 )

你可以在登录后,发表评论

搜索帮助