apache / rocketmq

Apache RocketMQ is a cloud native messaging and streaming platform, making it simple to build event-driven applications.
https://rocketmq.apache.org/
Apache License 2.0
21.29k stars 11.71k forks source link

NettyLogger#initNettyLogger method is overriding Netty's InternalLoggerFactory#defaultFactory #3516

Closed PilgrimOfNegentropy closed 2 years ago

PilgrimOfNegentropy commented 3 years ago

org.apache.rocketmq.remoting.netty.NettyLogger#initNettyLogger method sets the InternalLoggerFactory#defaultFactory to org.apache.rocketmq.remoting.netty.NettyLogger.NettyBridgeLoggerFactory overriding io.netty.util.internal.logging.Slf4JLoggerFactory

NettyBridgeLoggerFactory produces loggers whose isEnabled(InternalLogLevel internalLogLevel) method is:

return nettyLogLevel.ordinal() <= internalLogLevel.ordinal();

it returns false when the argument internalLogLevel is not greaterEqual than ERROR because org.apache.rocketmq.remoting.netty.NettyLogger#nettyLogLevel is ERROR and it has no accessor so it's value is never changed

io.netty.handler.logging.LoggingHandler uses InternalLoggerFactory to create loggers. Thus if it's initialized after the rocketmq client initialization, it creates a org.apache.rocketmq.remoting.netty.NettyLogger.NettyBridgeLogger instead of SLF4J's. Thus it never prints logs under ERROR level.

  1. Please tell us about your environment: Windows 10 19043.1348 Oracle jdk1.8.0_211 maven dependency:
    <dependency>
            <groupId>org.apache.rocketmq</groupId>
            <artifactId>rocketmq-spring-boot-starter</artifactId>
            <version>2.1.1</version>
    </dependency>
    <dependency>
        <groupId>io.netty</groupId>
        <artifactId>netty-all</artifactId>
        <version>4.1.27.Final</version>
    </dependency>

    I inspected the 4.9.2 version of rocketmq-client, it's the same code.

github-actions[bot] commented 2 years ago

This issue is stale because it has been open for 365 days with no activity. It will be closed in 3 days if no further activity occurs.

github-actions[bot] commented 2 years ago

This issue was closed because it has been inactive for 3 days since being marked as stale.

lastboy1228 commented 3 months ago

Set system property to use slf4j:

-Drocketmq.client.logUseSlf4j=true