Logback configuration issue, cannot find logback.xml

筅森魡賤 提交于 2019-12-12 02:00:00

问题


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:


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



来源:https://stackoverflow.com/questions/24080736/logback-configuration-issue-cannot-find-logback-xml

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!