Score
0
Watch 55 Star 121 Fork 45

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

Create your Gitee Account
Explore and code with more than 5 million developers,Free private repositories !:)
Sign up
收集java日志到Redis或者Kafka中的插件,日志收集完之后可使用ELK栈做分析(暂时只支持Logback) spread retract

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

Clone or download
Cancel
Notice: Creating folder will generate an empty file .keep, because not support in Git
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>

Comments ( 4 )

Sign in for post a comment

Java
1
https://gitee.com/jxttian/LoggingAppender.git
git@gitee.com:jxttian/LoggingAppender.git
jxttian
LoggingAppender
LoggingAppender日志收集插件
develop

Search

231008 48f1a665 1899542 231017 9a6720c6 1899542