Logback configuration issue, cannot find logback.x

2019-08-20 02:17发布

My project is configured to be able to pick up logback.xml automatically if it's located in the same directory as the .jar file. Normally I just run my project with java -jar app.jar and logback picks up logback.xml automatically and configures itself.

These are the contents of my MANIFEST.MF file:

Manifest-Version: 1.0
Archiver-Version: Plexus Archiver
Created-By: Apache Maven
Built-By: Dev
Build-Jdk: 1.7.0_45
Main-Class: com.app.middleware.App
Class-Path: .

However, once I added a new Maven dependency (ActiveMQ client 5.9.1), Logback seems to have become unable to pick up the configuration file from classpath - it simply prints the following:

20:17:58,872 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback.xml]
20:17:58,872 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Setting up default configuration.

I've extracted the old jar and the new jar alongside each other and both archives have the exact same contents of MANIFEST.MF and .classpath files.

Could this be caused by some kind of jar conflict introduced by ActiveMQ? Why would it prevent logback from picking up its configuration file?

I am currently getting around this problem by manually specifying the config location (-Dlogback.configurationFile=logback.xml) but I fear that this problem is a result of a deeper underlying issue.

1条回答
闹够了就滚
2楼-- · 2019-08-20 02:56

Put a logback.xml into the base package of your applications classpath.

查看更多
登录 后发表回答