使用 spring-DM 扩展器进行 OSGi 日志记录不进行日志记录

发布于 2024-08-31 18:34:18 字数 460 浏览 3 评论 0原文

我的设置:我能够使用 Log4J 作为我的日志记录框架创建一个简单的 OSGi 捆绑包,当部署到我的 OSGi 容器(Equinox)时,它工作得很好,我的日志记录配置非常简单,使用一个单独的捆绑包片段配置我的日志记录。该设置不涉及弹簧,而且效果非常好。

我的问题:我正在将一个使用 log4j 作为日志框架的 Spring 应用程序转换为 OSGi,第一阶段是为我的 Spring 应用程序创建各种捆绑包,现在我已经完成了。我遇到的问题是,与非 Spring 应用程序一起使用的 OSGi 日志片段包没有配置我的启用了 spring 的包。

我知道捆绑包处于活动状态,因为 system.out.println 确实有效,但是我的所有日​​志记录配置都不起作用。我在控制台中看不到任何内容,我确实看到很多 spring 输出,确认我的捆绑服务已公开,但没有日志记录。

任何建议表示赞赏。

My Setup: I am able to create a simple OSGi bundle with Log4J as my logging framework and when deployed to my OSGi container (Equinox) it works great my logging is configured very simply with a seperate bundle fragment that configures my logging. This setup does not have spring involved and it works really nicely.

My Issue: I am converting over a spring application which uses log4j as its logging framework to OSGi, the first stage was creating various bundles for my spring application which I have now completed. The problem I have is that the OSGi logging fragment bundle that worked with the non spring applications does not configure my spring enabled bundles.

I know the bundles are active as system.out.println does work however all my logging configuration is not working. I can see nothing in the console I do see a lot of spring output confirming my bundles services are exposed but no logging.

Any suggestions appreciated.

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

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

发布评论

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

评论(1

蹲在坟头点根烟 2024-09-07 18:34:18

我现在已经解决了这个问题,它花了我一天的时间,所以我希望有一天它能帮助别人。

我找到了文章 如何使用 Pax登录我的包,它提到确保我在 MANIFEST 中使用了以下内容。

Import-Package: org.apache.log4j; version="[1.2,1.3)"; provider=paxlogging,
 org.apache.commons.logging; version="[1.0,1.1)"; provider=paxlogging

此代码确保日志记录的提供者是 paxlogging。

没有它,我永远无法看到任何日志消息,现在我可以,这是很棒的配置,这似乎不适用于片段,所以我正在研究 ConfAdmin 为此,但现在我很高兴,可以通过适当的日志记录继续开发。

I have this now fixed, its has taken me the guts of a day so I hope it helps someone some day.

I found the article How to use Pax Logging in my bundles and it mentioned to make sure I used the following in my MANIFEST

Import-Package: org.apache.log4j; version="[1.2,1.3)"; provider=paxlogging,
 org.apache.commons.logging; version="[1.0,1.1)"; provider=paxlogging

This code makes sure that the provider for the logging is paxlogging.

Without it I never was able to see any of my logging messages now I can which is great configuring this does not seem to work with fragments so I am looking into ConfAdmin for this but for now I am happy and can continue development with proper logging.

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