I'm not able anymore to start my loggers using the gradle task `jettyRuǹ . The 1st issue with multiple bindings wasn't a problem. But now (after the upgrade to gradle 1.4, I guess) my loggers don't start. The slf4j doc says to reset the context programmatically, but I would prefer to do it by configuration as jettyRun is only used for development.
$ gradle jettyRun
:compileJava UP-TO-DATE
:processResources UP-TO-DATE
:classes UP-TO-DATE
:jettyRun
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/opt/gradle-1.4/lib/logback-classic-1.0.9.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/home/bertrand/.gradle/caches/artifacts-23/filestore/ch.qos.logback/logback-classic/1.0.9/jar/258c3d8f956e7c8723f13fdea6b81e3d74201f68/logback-classic-1.0.9.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 [ch.qos.logback.classic.util.ContextSelectorStaticBinder]
SLF4J: The following loggers will not work because they were created
SLF4J: during the default configuration phase of the underlying logging system.
SLF4J: See also http://www.slf4j.org/codes.html#substituteLogger
SLF4J: org.yajug.users.api.MembershipController
SLF4J: org.yajug.users.json.Serializer
SLF4J: org.yajug.users.api.MemberController
SLF4J: org.yajug.users.service.MemberServiceImpl
SLF4J: org.yajug.users.persistence.MongoConnector
The configuration is Logback-specific but works seamlessly with SLF4J. With the proper dependencies and configuration in place, the same code from previous sections can be used to handle the logging. 4. The Log4j Setup
Overview Simple Logging Facade for Java (abbreviated SLF4J) – acts as a facade for different logging frameworks (e.g. java.util.logging, logback, Log4j ). It offers a generic API making the logging independent of the actual implementation. This allows for different logging frameworks to coexist. It also helps migrate from one framework to another.
In the previous sections, we showed how the same code base can be used to support logging using different implementations. While this is the main promise and strength of SLF4J, it is also the goal behind JCL (Jakarta Commons Logging or Apache Commons Logging).
SLF4J will concatenate Strings only when the debug level is enabled. To do the same with Log4J you need to add extra if block which will check if debug level is enabled or not: SLF4J standardized the logging levels which are different for the particular implementations.
Finally I found what was wrong:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With