Slf4j + logback
See original GitHub issueDescribe the bug
First of all, I know that logback is not supported and JBoss Logging is the official logging framework. That being said, I manage to work with logback but found out that it only works in Profile prod and not in dev. I see a different behavior and that’s why I open this issue.
The problem arise at:
ch.qos.logback.classic.LoggerContext lc = (ch.qos.logback.classic.LoggerContext) org.slf4j.LoggerFactory.getILoggerFactory();
which works in profile prod but throws a ClassCastException in profile dev:
ERROR: 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 @73c9e8e8)
Expected behavior
I would expect the same behavior in both profiles (even if that would mean a failure on both)
To Reproduce
https://github.com/seseso/quarkus-logback
mvn clean package -DskipTests
java -jar target/quarkus-app/quarkus-run.jar
Works as excpeted
mvn quarkus:dev
ERROR: 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 @1a2b65ad)
Environment (please complete the following information):
Output of uname -a
or ver
Linux hp-spectre-x360 5.8.0-44-generic #50-Ubuntu SMP Tue Feb 9 06:29:41 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
Output of java -version
openjdk version “11.0.10” 2021-01-19 OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.10+9) OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.10+9, mixed mode)
GraalVM version (if different from Java)
N/A - Don’t need to run in native mode
Quarkus version or git rev
1.12.2-Final
Build tool (ie. output of mvnw --version
or gradlew --version
)
Apache Maven 3.6.3
Issue Analytics
- State:
- Created 3 years ago
- Comments:13 (9 by maintainers)
For me, something like
TurboFilter
(http://logback.qos.ch/manual/filters.html) would come in handy as well.E.g. to suppress specific WARN and ERROR messages while doing negative tests.
@eriknyk Loggly can be used via rsyslog, and Quarkus has a syslog happen, see https://quarkus.io/guides/logging#syslog-log-handler
@seseso the issue with dev mode may be due to its classloader, can you try to register logback as a parent first dependency to see if it solves the issu? See https://quarkus.io/guides/class-loading-reference#parent-first-dependencies