hivemq-community-edition
hivemq-community-edition copied to clipboard
FR: Allow for other slf4j-api implementations
Problem or use case
the broker does not allow the use of any other implementation of the slf4j-api. normally an application uses only the slf4j-api and leaves it up to the user to decide which slf4j-api-implementation to use.
but if you exclude logback-classic the embedded broker hangs up in HiveMQServer.bootstrap() by calling LoggingBootstrap.prepareLogging();
Preferred solution or suggestions
the embedded broker should only use the slf4j-api and leave it up to the user to decide which implementation he wants/can/must use.
Hi @john2home - thanks for pointing this issue out. It's a fair request and makes sense.
I filed this in our feature request database. If I hear anything back, I'll make sure to update this issue.
I totally agree about this issue. Solving this issue will also solve #319, which I think was inappropriately closed. Using slf4j-api, there's no reason to not support other logging frameworks. Both this issue and #319 has the same solution: Use slf4j-api.
Additionally, I have found that using com.hivemq:hivemq-community-edition-embedded:2023.2
in combination with ch.qos.logback:logback-core:1.1.11
is working, but ch.qos.logback:logback-core:1.4.6
(latest version as of today) is not working. It fails at:
ch.qos.logback.classic.util.ContextInitializer.configureByResource(ContextInitializer.java:62)
with the error: java.lang.NoClassDefFoundError: ch/qos/logback/core/joran/action/AbstractEventEvaluatorAction
Changing the implementation of ContextInitializer.configureByResource
is a good first step to solve these issues.
I have an issue embedding HiveMQ into a Quarkus app, related to this.
Caused by: java.lang.ClassCastException: class org.slf4j.impl.Slf4jLoggerFactory cannot be cast to class ch.qos.logback.classic.LoggerContext (org.slf4j.impl.Slf4jLoggerFactory is in unnamed module of loader 'app'; ch.qos.logback.classic.LoggerContext is in unnamed module of loader io.quarkus.bootstrap.classloading.QuarkusClassLoader @55b53d44)
at com.hivemq.bootstrap.LoggingBootstrap.getRootLogger(LoggingBootstrap.java:145)
at com.hivemq.bootstrap.LoggingBootstrap.prepareLogging(LoggingBootstrap.java:67)
at com.hivemq.HiveMQServer.bootstrap(HiveMQServer.java:108)
at com.hivemq.embedded.internal.EmbeddedHiveMQImpl.stateChange(EmbeddedHiveMQImpl.java:150)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)