在Spring-OSGI中使用pax-runner登录 [英] logback in spring-OSGI with pax-runner

查看:72
本文介绍了在Spring-OSGI中使用pax-runner登录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在使用pax-runner运行 OSGI 捆绑软件.我们正在通过slf4j使用logback进行记录.

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

问题是 logback 试图在类路径中查找logback.xml,但是在 pax-runner 中应该放置logback.xml的位置,以便pax-runner配置logback相应地?

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?

我已经尝试使用JoranConfigurator加载包类路径中包含的logback.xml,但是它假定类路径是包在其中运行的容器(在我的情况下,它是放置所有包jar的Runner文件夹).

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).

任何帮助将不胜感激.

谢谢你.

推荐答案

通常的方法是创建一个片段束,该束附加到logback束中,并将logback.xml放在其中.片段捆绑包会扩展"其他捆绑包,因此主机捆绑包的类加载器可以使用它们的内容.这样,logback可以在类路径中找到logback.xml.

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.

这篇关于在Spring-OSGI中使用pax-runner登录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆