question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Describe 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:open
  • Created 3 years ago
  • Comments:13 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
famodcommented, Apr 1, 2021

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.

1reaction
loicmathieucommented, Mar 26, 2021

@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

Read more comments on GitHub >

github_iconTop Results From Across the Web

SLF4J Logback Tutorial - Mkyong.com
A simple SLF4J with Logback example. Tested with. SLF4J API 1.7.25; Logback 1.2.3; Maven 3; Java 8. Note Logback natively implements the SLF4J...
Read more >
SLF4J Manual
The Simple Logging Facade for Java (SLF4J) serves as a simple facade or abstraction for various logging frameworks, such as java.util.logging, logback and ......
Read more >
A Guide To Logback - Baeldung
A quick and to the point guide of how to use Log4j2 and Logback with SLF4J, as well as how to bridge other...
Read more >
Setting Up SLF4J with Logback, Log4j2 and JUL
When using Logback with SLF4j, a console appender with DEBUG log level is configured automatically. For custom logback configuration, we need to create...
Read more >
Logback Home
Moreover, logback-classic natively implements the SLF4J API so that you can readily switch back and forth between logback and other logging frameworks such...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found