I'm struggling with getting Eclipse to recognize my logging configuration when I quick run tests from within Eclipse (Alt + Shift + X, T), or by running from the Run Configurations. I really don't care all that much about logging from the tests per se, but really just providing the configuration so that any log statements executed will not fail.
Failed to instantiate [ch.qos.logback.classic.LoggerContext]
Reported exception:
java.lang.NoSuchMethodError: ch.qos.logback.core.util.Loader.getResourceOccurrenceCount(Ljava/lang/String;Ljava/lang/ClassLoader;)Ljava/util/Set;
at ch.qos.logback.classic.util.ContextInitializer.multiplicityWarning(ContextInitializer.java:160)
at ch.qos.logback.classic.util.ContextInitializer.statusOnResourceSearch(ContextInitializer.java:183)
at ch.qos.logback.classic.util.ContextInitializer.getResource(ContextInitializer.java:141)
at ch.qos.logback.classic.util.ContextInitializer.findURLOfDefaultConfigurationFile(ContextInitializer.java:130)
at ch.qos.logback.classic.util.ContextInitializer.autoConfig(ContextInitializer.java:148)
at org.slf4j.impl.StaticLoggerBinder.init(StaticLoggerBinder.java:85)
at org.slf4j.impl.StaticLoggerBinder.<clinit>(StaticLoggerBinder.java:55)
at org.slf4j.LoggerFactory.bind(LoggerFactory.java:144)
at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:123)
at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:337)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:287)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:309)
I have logback-test.xml in src/test/resources, and have configured that as a source folder with an output of target/test-classes.
I even took at shot at editing the Classpath of the Run Configuration for JUnit for my project, and added the test-classes folder there, and it didn't help.
Is there something simple that I'm missing? I don't seem to recall having this issue in the past with other projects.
When you run your project, configure the CLASSPATH and add the location of the logback. xml files by clicking on: Run As ->Run Configuration -> Classpath tab -> click on User Entries -> Advanced -> select Add Folder -> select the location of your logback. xml file and then -> OK -> Run.
To configure Logback for a Spring Boot project via XML, create the logback. xml or logback-spring. xml file under the src/main/resources folder.
I checked my pom.xml, and logback-classic didn't have a specified version, and logback-core did. I set a property for the version and set them both to be the same.
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