Support using another slf4j backend than logback
See original GitHub issueWe are using gatling 2.2.5 as part of our maven build process, and as such, it does inheritance all the libraries our product uses : slf4j, log4j1.x, log4j2.x ( i know, i know , but it’s a legacy product can’t be changed ).
The usage of logback inside gatling conflicts with these libraries, as there’s a race condition between them, so we’re giving an error :
SLF4J: Found binding in [jar:file:/D:/Users/OU83MP/.m2/repository/org/apache/logging/log4j/log4j-slf4j-impl/2.2/log4j-slf4j-impl-2.2.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/D:/Users/OU83MP/.m2/repository/org/slf4j/slf4j-log4j12/1.7.5/slf4j-log4j12-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/D:/Users/OU83MP/.m2/repository/ch/qos/logback/logback-classic/1.1.7/logback-classic-1.1.7.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory]
15:08:00.845 [main] TRACE io.gatling.app.Gatling$ - Starting
15:08:00.942 [main] TRACE io.gatling.app.Gatling$ - Configuration loaded
15:08:01.251 [GatlingSystem-akka.actor.default-dispatcher-4] INFO akka.event.slf4j.Slf4jLogger - Slf4jLogger started
15:08:01.251 [main] TRACE io.gatling.app.Gatling$ - ActorSystem instantiated
15:08:01.266 [main] TRACE io.gatling.app.Gatling$ - Runner instantiated
15:08:01.358 [main] TRACE io.gatling.app.Runner - Running
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at io.gatling.mojo.MainWithArgsInFile.runMain(MainWithArgsInFile.java:50)
at io.gatling.mojo.MainWithArgsInFile.main(MainWithArgsInFile.java:33)
Caused by: java.lang.ClassCastException: org.apache.logging.slf4j.Log4jLoggerFactory cannot be cast to ch.qos.logback.classic.LoggerContext
If we exclude the logback dependency, we get a ClassNotFoundException. If we exclude the slf4j/log4j2 dependencies, problem still persists.
Would’nt it be better to use the slf4j-api inside gatling, and not impose the ( great ) logback impl ?
Issue Analytics
- State:
- Created 6 years ago
- Comments:10 (7 by maintainers)
Top Results From Across the Web
Support using another slf4j backend than logback #3340
We are using gatling 2.2.5 as part of our maven build process, and as such, it does inheritance all the libraries our product...
Read more >SLF4J Manual
Logging backends are free and even encouraged to offer a more customizable behaviour. Binding with a logging framework at deployment time. As mentioned ......
Read more >Logback native VS Logback via SLF4J - java - Stack Overflow
Logback is not build on top of SLF4J. SLF4J is an abstraction framework for logging. It doesn't do any logging itself. It just...
Read more >Introduction to SLF4J - 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 >Java Logging Frameworks: log4j vs logback vs log4j2 - Stackify
Log4j, Logback, and log4j2 are all broadly used logging frameworks. What's the difference between them and which one should you prefer?
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi @slandelle I am fine with
gatling
shipping withLogback
like before. I was in fact suggesting that above.Could you please revert @sebastianvoss’s change to this line and catch the
ClassNotFoundException
instead? That would resolve this issue.I can send a pull request if you prefer that with the change below.
Catching the exception would really help the logs look clean. Also since it appears that
log4j2
doesn’t have astop
method, the new warning message is not accurate. Thank you.@testphreak Sorry, got distracted by some other stuff. Will do so by end of today.