使用 pax-runner 在 spring-OSGI 中进行 logback

发布于 2024-09-29 06:15:47 字数 368 浏览 0 评论 0原文

我们正在使用 pax-runner 运行 OSGI 捆绑包。我们通过 slf4j 使用 logback 进行日志记录。

问题是 logback 尝试在类路径中查找 logback.xml,但是在 pax-runner 中我应该将 logback.xml 放置在哪里,以便 pax-runner 相应地配置 logback?

我尝试使用 JoranConfigurator 加载包含在捆绑包类路径中的 logback.xml,但它假定类路径作为捆绑包运行的容器(在我的情况下,它是放置所有捆绑包 jar 的运行程序文件夹)。

任何帮助将不胜感激。

提前致谢。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

筱果果 2024-10-06 06:15:47

通常的方法是创建一个附加到 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.

毁梦 2024-10-06 06:15:47

另一个解决方案是配置 logback 来读取配置
来自类路径外部的文件。

这可以通过设置 VM 选项 -Dlogback.configurationFile=/dir/conf/logback.xml 来完成

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文