logback in spring-OSGI with pax-runner

爱⌒轻易说出口 提交于 2019-12-05 03:43:15

问题


We are running OSGI bundles with pax-runner. We are logging using logback over slf4j.

The problem is logback tries to look for logback.xml in classpath, but in pax-runner where should I place logback.xml so that pax-runner configure logback accordingly?

I have tried with JoranConfigurator to load logback.xml which is included in bundle classpath, but it assumes classpath as the container in which the bundle is running (in my case it is runner folder where all the bundle jars are placed).

Any help would be appreciated.

Thanks in advace.


回答1:


The usual approach would be to create a fragment bundle that is attached to the logback bundle and put logback.xml in there. Fragment bundles "extend" other bundles, so their contents are available to the classloader of the host bundle. This way, logback can find logback.xml in the classpath.




回答2:


Another solution would be to configure logback to read the configuration file from outside the classpath.

This can be done by setting VM options -Dlogback.configurationFile=/dir/conf/logback.xml



来源:https://stackoverflow.com/questions/4031731/logback-in-spring-osgi-with-pax-runner

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