Giter Site home page Giter Site logo

rocketmq-logging's Introduction

Logging for Apache RocketMQ

License build Maven Central

Introduction

Inspired by glowroot, this project aims to provide a shaded SLF4J/Logback, making it possible to create an isolated environment for the logging system of Apache RocketMQ.

Requirements

  • Java 1.8 or later

Getting Started

Add the following dependency to your project. Remember to replace ROCKETMQ-LOGGING-VERSION with the latest release.

<dependencies>
    <dependency>
        <groupId>io.github.aliyun-mq</groupId>
        <artifactId>rocketmq-slf4j-api</artifactId>
        <version>ROCKETMQ-LOGGING-VERSION</version>
    </dependency>
    <dependency>
        <groupId>io.github.aliyun-mq</groupId>
        <artifactId>rocketmq-logback-classics</artifactId>
        <version>ROCKETMQ-LOGGING-VERSION</version>
    </dependency>
</dependencies>

This project uses different configuration files, which are different from logback, you need to configure rmq.logback-test.xml/rmq.logback.xml instead.

Besides, this library provides some extensions from logback, you can check them below.

A configuration example can be found here:

<?xml version="1.0" encoding="UTF-8"?>
<configuration debug="false">
    <conversionRule conversionWord="pid" converterClass="io.github.aliyunmq.logback.extensions.ProcessIdConverter"/>
    <appender name="CustomConsoleAppender" class="io.github.aliyunmq.logback.extensions.CustomConsoleAppender">
        <encoder>
            <pattern>%yellow(%d{yyy-MM-dd HH:mm:ss.SSS,GMT+8}) %highlight(%-5p) %boldWhite([%pid]) %magenta([%t]) %boldGreen([%logger{12}#%M:%L]) - %m%n
            </pattern>
            <charset class="java.nio.charset.Charset">UTF-8</charset>
        </encoder>
    </appender>
    <appender name="DefaultAppender" class="org.apache.rocketmq.shade.ch.qos.logback.core.rolling.RollingFileAppender">
        <append>true</append>
        <File>
            ${rocketmq.log.root:-${user.home}${file.separator}logs${file.separator}rocketmq}${file.separator}rocketmq-client.log
        </File>
        <rollingPolicy class="org.apache.rocketmq.shade.ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
            <FileNamePattern>
                ${rocketmq.log.root:-${user.home}${file.separator}logs${file.separator}rocketmq}${file.separator}other_days${file.separator}rocketmq-client-%i.log.gz
            </FileNamePattern>
            <minIndex>1</minIndex>
            <maxIndex>${rocketmq.log.file.maxIndex:-10}</maxIndex>
        </rollingPolicy>
        <triggeringPolicy class="org.apache.rocketmq.shade.ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
            <maxFileSize>64MB</maxFileSize>
        </triggeringPolicy>
        <encoder class="org.apache.rocketmq.shade.ch.qos.logback.classic.encoder.PatternLayoutEncoder">
            <pattern>%d{yyy-MM-dd HH:mm:ss.SSS,GMT+8} %-5p [%t] [%logger{12}#%M:%L] - %m%n</pattern>
            <charset class="java.nio.charset.Charset">UTF-8</charset>
        </encoder>
    </appender>
    <root level="${rocketmq.log.level:-info}">
        <appender-ref ref="CustomConsoleAppender"/>
        <appender-ref ref="DefaultAppender" additivity="false"/>
    </root>
</configuration>

Manual Release

Set the password in your settings.xml for repositories: sonatype-nexus-snapshots-aliyun-mq and sonatype-nexus-staging-aliyun-mq, then execute the command below:

mvn clean deploy -Prelease

Sign in nexus repository manager and check the artifact, then determine whether to release it.

Related Projects

License

Apache License, Version 2.0 Copyright (C) Apache Software Foundation

rocketmq-logging's People

Contributors

aaron-ai avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.