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.
- Java 1.8 or later
Add the following dependency to your project. Remember to replace ROCKETMQ-LOGGING-VERSION
with
the latest release.
<dependencies>
<dependency>
<groupId>io.github.aliyunmq</groupId>
<artifactId>rocketmq-slf4j-api</artifactId>
<version>ROCKETMQ-LOGGING-VERSION</version>
</dependency>
<dependency>
<groupId>io.github.aliyunmq</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.
- io.github.aliyunmq.logback.extensions.CustomConsoleAppender
- io.github.aliyunmq.logback.extensions.ProcessIdConverter
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>
Set the password in your settings.xml
for repositories: sonatype-nexus-snapshots-aliyunmq
and sonatype-nexus-staging-aliyunmq
, then execute the command below:
mvn clean deploy -Prelease
Sign in nexus repository manager and check the artifact, then determine whether to release it.
- rocketmq-slf4j-api-bridge: Bridge for SLF4J API of Apache RocketMQ.
Apache License, Version 2.0 Copyright (C) Apache Software Foundation