iloveeyjafjalla opened a new issue, #11431:
URL: https://github.com/apache/rocketmq/issues/11431

   ### Before Creating the Bug Report
   
   - [x] I found a bug, not just asking a question, which should be created in 
[GitHub Discussions](https://github.com/apache/rocketmq/discussions).
   - [x] I have searched the [GitHub 
Issues](https://github.com/apache/rocketmq/issues) and [GitHub 
Discussions](https://github.com/apache/rocketmq/discussions) of this repository 
and believe that this is not a duplicate.
   - [x] I have confirmed that this bug belongs to the current repository, not 
other repositories of RocketMQ.
   
   ### Runtime platform environment
   
   OS: any (the `mqadmin` tool)
   
   ### RocketMQ version
   
   branch: develop
   Git commit id: a7edeecfb
   
   ### JDK Version
   
   Compiler: Temurin 1.8.0_504 (target 1.8, same as CI)
   
   ### Describe the Bug
   
   `tools/src/main/resources/rmq.tools.logback.xml` — the configuration the 
distribution installs as `conf/rmq.tools.logback.xml` and that `mqadmin` 
selects with `-Drmq.logback.configurationFile` (`distribution/bin/mqadmin:45`) 
— attaches three loggers to an appender it never defines:
   
   ```xml
   <logger name="RocketmqCommon" additivity="false" level="INFO">
       <appender-ref ref="RocketmqBrokerAppender"/>     <!-- not defined in 
this file -->
   </logger>
   <logger name="RocketmqStore" additivity="false" level="INFO">
       <appender-ref ref="RocketmqBrokerAppender"/>
   </logger>
   <logger name="RocketmqRemoting" additivity="false" level="INFO">
       <appender-ref ref="RocketmqBrokerAppender"/>
   </logger>
   ```
   
   The appenders this file defines are `DefaultAppender`, 
`RocketmqToolsAppender`, `RocketmqToolsAppender_inner` and `STDOUT`; 
`RocketmqBrokerAppender` only exists in the *broker* and *proxy* 
configurations, and logback resolves `appender-ref`s inside the configuration 
file that is being loaded, so the reference cannot be satisfied.
   
   Two consequences, both user-visible:
   
   1. every `mqadmin` invocation prints three configuration errors before doing 
any work — `ERROR in ch.qos.logback.core.joran.action.AppenderRefAction - Could 
not find an appender named [RocketmqBrokerAppender]. Did you define it below 
instead of above?`;
   2. because those loggers also set `additivity="false"` and their only 
reference is dropped, everything logged through `RocketmqCommon`, 
`RocketmqStore` and `RocketmqRemoting` is discarded — nothing from the 
client/store/remoting layers reaches `tools.log` (or any appender), which is 
exactly the diagnostic trail an operator needs when a tool misbehaves.
   
   The sibling configurations do this correctly, which is the pattern to keep: 
broker points those loggers at its own `RocketmqBrokerAppender`, namesrv at 
`RocketmqNamesrvAppender` 
(`namesrv/src/main/resources/rmq.namesrv.logback.xml:94-100`), proxy at its 
`RocketmqBrokerAppender`. This is the same class of mistake that was fixed in 
#11177 (an appender registered under a name that did not match its definition).
   
   ### Steps to Reproduce
   
   1. Run any admin command, e.g. `mqadmin clusterList -n 127.0.0.1:9876` (the 
wrapper passes `conf/rmq.tools.logback.xml`).
   2. Observe the three `Could not find an appender named 
[RocketmqBrokerAppender]` errors printed by logback before the command output.
   3. Check `${user.home}/logs/rocketmqlogs/tools.log`: nothing logged by 
`RocketmqCommon`/`RocketmqStore`/`RocketmqRemoting` ever appears there.
   
   At the unit level the shipped file is loaded with the project's own 
`JoranConfiguratorExt` (`common/.../logging/JoranConfiguratorExt.java`, the 
loader that also rewrites the unshaded logback class names for the shaded 
runtime) into a fresh logger context with a status collector — the 
missing-appender error is reported as an error status and the three loggers end 
up with no appender.
   
   ### What Did You Expect to See?
   
   `mqadmin` starts without configuration errors, and its component loggers 
write to the tool's own log file — i.e. the three loggers reference 
`RocketmqToolsAppender` (the appender the file defines and that `RocketmqTools` 
already uses, writing to `${user.home}/logs/rocketmqlogs/tools.log`), mirroring 
how each other component points those loggers at its own appender.
   
   ### What Did You See Instead?
   
   Three logback errors on every invocation and three loggers whose output is 
silently discarded.
   
   ### Additional Context
   
   Minimal fix: replace the three `RocketmqBrokerAppender` references with 
`RocketmqToolsAppender`. I checked the other shipped configurations for the 
same mistake: only this file references an appender it does not define (the 
controller file defines `RocketmqControllerConsole` twice, but with identical 
content, which logback merges harmlessly).
   
   I will open a PR with the three-line change plus a regression test that 
loads the shipped `rmq.tools.logback.xml` through `JoranConfiguratorExt` and 
asserts there are no configuration errors and that the three loggers are 
attached to an appender (red before: the error status appears and the appender 
list is empty).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to