Skip to content

Commit

Permalink
[ISSUE apache#5484] Replace logging module with the shaded logback (a…
Browse files Browse the repository at this point in the history
…pache#5540)

* Replace logging module with the shaded logback

* Add license header

* Fix bazel compile issue
  • Loading branch information
aaron-ai authored Nov 21, 2022
1 parent 991af5e commit a68078f
Show file tree
Hide file tree
Showing 419 changed files with 2,036 additions and 6,119 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
.settings/
target/
devenv
*.log*
*.log.*
*.iml
.idea/
*.versionsBackup
Expand Down
1 change: 1 addition & 0 deletions .licenserc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ header:
- 'distribution/NOTICE-BIN'
- 'distribution/conf/rmq-proxy.json'
- '.bazelversion'
- 'common/src/main/resources/META-INF/services/org.apache.rocketmq.logging.ch.qos.logback.classic.spi.Configurator'


comment: on-failure
7 changes: 4 additions & 3 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ maven_install(
"com.alibaba:fastjson:1.2.76",
"org.hamcrest:hamcrest-library:1.3",
"io.netty:netty-all:4.1.65.Final",
"org.slf4j:slf4j-api:1.7.7",
"org.slf4j:slf4j-api:1.7.33",
"org.assertj:assertj-core:3.22.0",
"org.mockito:mockito-core:3.10.0",
"com.github.luben:zstd-jni:1.5.2-2",
Expand All @@ -64,7 +64,6 @@ maven_install(
"org.yaml:snakeyaml:1.30",
"commons-codec:commons-codec:1.13",
"commons-io:commons-io:2.7",
"log4j:log4j:1.2.17",
"com.google.truth:truth:0.30",
"org.bouncycastle:bcpkix-jdk15on:1.69",
"com.google.code.gson:gson:2.8.9",
Expand All @@ -73,7 +72,7 @@ maven_install(
"com.google.protobuf:protobuf-java:3.20.1",
"com.google.protobuf:protobuf-java-util:3.20.1",
"com.conversantmedia:disruptor:1.2.10",
"javax.annotation:javax.annotation-api:1.3.2",
"org.apache.tomcat:annotations-api:6.0.53",
"com.google.code.findbugs:jsr305:3.0.2",
"org.checkerframework:checker-qual:3.12.0",
"org.reflections:reflections:0.9.11",
Expand All @@ -94,6 +93,8 @@ maven_install(
"io.opentelemetry:opentelemetry-api:1.19.0",
"io.opentelemetry:opentelemetry-sdk-metrics:1.19.0",
"io.opentelemetry:opentelemetry-sdk-common:1.19.0",
"io.github.aliyun-mq:rocketmq-slf4j-api:1.0.4",
"io.github.aliyun-mq:rocketmq-logback-classic:1.0.4",
],
fetch_sources = True,
repositories = [
Expand Down
3 changes: 2 additions & 1 deletion acl/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ java_library(
visibility = ["//visibility:public"],
deps = [
"//common",
"//logging",
"//remoting",
"//srvutil",
"@maven//:com_alibaba_fastjson",
Expand All @@ -36,6 +35,8 @@ java_library(
"@maven//:org_apache_rocketmq_rocketmq_proto",
"@maven//:org_lz4_lz4_java",
"@maven//:org_yaml_snakeyaml",
"@maven//:io_github_aliyun_mq_rocketmq_slf4j_api",
"@maven//:io_github_aliyun_mq_rocketmq_logback_classic",
],
)

Expand Down
23 changes: 8 additions & 15 deletions acl/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@
<groupId>${project.groupId}</groupId>
<artifactId>rocketmq-remoting</artifactId>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>rocketmq-logging</artifactId>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>rocketmq-common</artifactId>
Expand All @@ -43,6 +39,14 @@
<groupId>${project.groupId}</groupId>
<artifactId>rocketmq-srvutil</artifactId>
</dependency>
<dependency>
<groupId>io.github.aliyun-mq</groupId>
<artifactId>rocketmq-slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>io.github.aliyun-mq</groupId>
<artifactId>rocketmq-logback-classic</artifactId>
</dependency>
<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
Expand All @@ -55,17 +59,6 @@
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>commons-validator</groupId>
<artifactId>commons-validator</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@
import javax.crypto.spec.SecretKeySpec;
import org.apache.commons.codec.binary.Base64;
import org.apache.rocketmq.common.constant.LoggerName;
import org.apache.rocketmq.logging.InternalLogger;
import org.apache.rocketmq.logging.InternalLoggerFactory;
import org.apache.rocketmq.logging.org.slf4j.Logger;
import org.apache.rocketmq.logging.org.slf4j.LoggerFactory;

public class AclSigner {
public static final Charset DEFAULT_CHARSET = StandardCharsets.UTF_8;
public static final SigningAlgorithm DEFAULT_ALGORITHM = SigningAlgorithm.HmacSHA1;
private static final InternalLogger log = InternalLoggerFactory.getLogger(LoggerName.ROCKETMQ_AUTHORIZE_LOGGER_NAME);
private static final Logger log = LoggerFactory.getLogger(LoggerName.ROCKETMQ_AUTHORIZE_LOGGER_NAME);
private static final int CAL_SIGNATURE_FAILED = 10015;
private static final String CAL_SIGNATURE_FAILED_MSG = "[%s:signature-failed] unable to calculate a request signature. error=%s";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@

import org.apache.commons.lang3.StringUtils;
import org.apache.rocketmq.common.constant.LoggerName;
import org.apache.rocketmq.logging.InternalLogger;
import org.apache.rocketmq.logging.InternalLoggerFactory;
import org.apache.rocketmq.logging.org.slf4j.Logger;
import org.apache.rocketmq.logging.org.slf4j.LoggerFactory;
import org.apache.rocketmq.remoting.RPCHook;
import org.apache.rocketmq.remoting.protocol.RemotingCommand;
import org.yaml.snakeyaml.Yaml;
Expand All @@ -37,7 +37,7 @@

public class AclUtils {

private static final InternalLogger log = InternalLoggerFactory.getLogger(LoggerName.COMMON_LOGGER_NAME);
private static final Logger log = LoggerFactory.getLogger(LoggerName.COMMON_LOGGER_NAME);

public static byte[] combineRequestContent(RemotingCommand request, SortedMap<String, String> fieldsMap) {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@
import org.apache.rocketmq.common.PlainAccessConfig;
import org.apache.rocketmq.common.constant.LoggerName;
import org.apache.rocketmq.common.topic.TopicValidator;
import org.apache.rocketmq.logging.InternalLogger;
import org.apache.rocketmq.logging.InternalLoggerFactory;
import org.apache.rocketmq.logging.org.slf4j.Logger;
import org.apache.rocketmq.logging.org.slf4j.LoggerFactory;
import org.apache.rocketmq.remoting.protocol.DataVersion;
import org.apache.rocketmq.srvutil.AclFileWatchService;

public class PlainPermissionManager {

private static final InternalLogger log = InternalLoggerFactory.getLogger(LoggerName.COMMON_LOGGER_NAME);
private static final Logger log = LoggerFactory.getLogger(LoggerName.COMMON_LOGGER_NAME);

private String fileHome = System.getProperty(MixAll.ROCKETMQ_HOME_PROPERTY,
System.getenv(MixAll.ROCKETMQ_HOME_ENV));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@
import org.apache.rocketmq.acl.common.AclException;
import org.apache.rocketmq.acl.common.AclUtils;
import org.apache.rocketmq.common.constant.LoggerName;
import org.apache.rocketmq.logging.InternalLogger;
import org.apache.rocketmq.logging.InternalLoggerFactory;
import org.apache.rocketmq.logging.org.slf4j.Logger;
import org.apache.rocketmq.logging.org.slf4j.LoggerFactory;

public class RemoteAddressStrategyFactory {

private static final InternalLogger log = InternalLoggerFactory.getLogger(LoggerName.COMMON_LOGGER_NAME);
private static final Logger log = LoggerFactory.getLogger(LoggerName.COMMON_LOGGER_NAME);

public static final NullRemoteAddressStrategy NULL_NET_ADDRESS_STRATEGY = new NullRemoteAddressStrategy();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,20 @@
-->
<configuration>

<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{5} - %msg%n</pattern>
<charset class="java.nio.charset.Charset">UTF-8</charset>
</encoder>
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<layout class="ch.qos.logback.classic.PatternLayout">
<Pattern>
%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n
</Pattern>
</layout>
</appender>

<logger name="RocketmqCommon" level="INFO" additivity="false">
<appender-ref ref="STDOUT"/>
<logger name="org.apache.rocketmq" level="error" additivity="false">
<appender-ref ref="CONSOLE"/>
</logger>
<root level="INFO">
<appender-ref ref="STDOUT"/>

<root level="error">
<appender-ref ref="CONSOLE"/>
</root>

</configuration>
</configuration>
6 changes: 3 additions & 3 deletions broker/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ java_library(
"//client",
"//common",
"//filter",
"//logging",
"//remoting",
"//srvutil",
"//store",
Expand All @@ -50,6 +49,8 @@ java_library(
"@maven//:org_apache_commons_commons_lang3",
"@maven//:org_lz4_lz4_java",
"@maven//:org_slf4j_slf4j_api",
"@maven//:io_github_aliyun_mq_rocketmq_slf4j_api",
"@maven//:io_github_aliyun_mq_rocketmq_logback_classic",
],
)

Expand All @@ -60,7 +61,7 @@ java_library(
"src/test/resources/META-INF/service/org.apache.rocketmq.acl.AccessValidator",
"src/test/resources/META-INF/service/org.apache.rocketmq.broker.transaction.AbstractTransactionalMessageCheckListener",
"src/test/resources/META-INF/service/org.apache.rocketmq.broker.transaction.TransactionalMessageService",
"src/test/resources/logback-test.xml",
"src/test/resources/rmq.logback-test.xml",
],
visibility = ["//visibility:public"],
deps = [
Expand All @@ -70,7 +71,6 @@ java_library(
"//client",
"//common",
"//filter",
"//logging",
"//remoting",
"//store",
"@maven//:com_alibaba_fastjson",
Expand Down
16 changes: 6 additions & 10 deletions broker/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,12 @@
<artifactId>rocketmq-store</artifactId>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>rocketmq-remoting</artifactId>
<groupId>io.github.aliyun-mq</groupId>
<artifactId>rocketmq-slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>io.github.aliyun-mq</groupId>
<artifactId>rocketmq-logback-classic</artifactId>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
Expand All @@ -58,10 +62,6 @@
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
Expand All @@ -70,10 +70,6 @@
<groupId>org.javassist</groupId>
<artifactId>javassist</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcpkix-jdk15on</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@
import org.apache.rocketmq.common.message.MessageExtBrokerInner;
import org.apache.rocketmq.common.stats.MomentStatsItem;
import org.apache.rocketmq.common.utils.ServiceProvider;
import org.apache.rocketmq.logging.InternalLogger;
import org.apache.rocketmq.logging.InternalLoggerFactory;
import org.apache.rocketmq.logging.org.slf4j.Logger;
import org.apache.rocketmq.logging.org.slf4j.LoggerFactory;
import org.apache.rocketmq.remoting.Configuration;
import org.apache.rocketmq.remoting.RPCHook;
import org.apache.rocketmq.remoting.RemotingServer;
Expand Down Expand Up @@ -159,9 +159,9 @@
import org.apache.rocketmq.store.timer.TimerMetrics;

public class BrokerController {
protected static final InternalLogger LOG = InternalLoggerFactory.getLogger(LoggerName.BROKER_LOGGER_NAME);
private static final InternalLogger LOG_PROTECTION = InternalLoggerFactory.getLogger(LoggerName.PROTECTION_LOGGER_NAME);
private static final InternalLogger LOG_WATER_MARK = InternalLoggerFactory.getLogger(LoggerName.WATER_MARK_LOGGER_NAME);
protected static final Logger LOG = LoggerFactory.getLogger(LoggerName.BROKER_LOGGER_NAME);
private static final Logger LOG_PROTECTION = LoggerFactory.getLogger(LoggerName.PROTECTION_LOGGER_NAME);
private static final Logger LOG_WATER_MARK = LoggerFactory.getLogger(LoggerName.WATER_MARK_LOGGER_NAME);
protected static final int HA_ADDRESS_MIN_LENGTH = 6;

protected final BrokerConfig brokerConfig;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
import org.apache.rocketmq.common.MixAll;
import org.apache.rocketmq.common.ServiceThread;
import org.apache.rocketmq.common.constant.LoggerName;
import org.apache.rocketmq.logging.InternalLogger;
import org.apache.rocketmq.logging.InternalLoggerFactory;
import org.apache.rocketmq.logging.org.slf4j.Logger;
import org.apache.rocketmq.logging.org.slf4j.LoggerFactory;
import org.apache.rocketmq.remoting.common.RemotingHelper;
import org.apache.rocketmq.remoting.protocol.BrokerSyncInfo;
import org.apache.rocketmq.remoting.protocol.body.BrokerMemberGroup;
Expand All @@ -41,7 +41,7 @@
import org.apache.rocketmq.store.timer.TimerCheckpoint;

public class BrokerPreOnlineService extends ServiceThread {
private static final InternalLogger LOGGER = InternalLoggerFactory.getLogger(LoggerName.BROKER_LOGGER_NAME);
private static final Logger LOGGER = LoggerFactory.getLogger(LoggerName.BROKER_LOGGER_NAME);
private final BrokerController brokerController;

private int waitBrokerIndex = 0;
Expand Down
Loading

0 comments on commit a68078f

Please sign in to comment.