使用 Equinox Servle Bridge 将 OSGi 应用程序部署到 Tomcat 时如何配置 Log4J?

发布于 2024-07-16 08:36:30 字数 907 浏览 4 评论 0原文

使用 equinox servlet 桥 部署我的 OSGi Web 应用程序时,我得到以下信息:

log4j:WARN No appenders could be found for logger (org.springframework.osgi.extender.internal.activator.ContextLoaderListener).
log4j:WARN Please initialize the log4j system properly.

我尝试了几种提供必要的“log4j.properties”文件的方法,包括:

  • 将上下文参数“log4jConfigLocation”添加到servlet桥web.xml中,
  • 在WEB-INF文件夹中创建文件夹“classes”并复制我的log4j.properties那里的文件(并将其复制到其他几个位置)
  • 删除我的 log4j 包并将“extendedFrameworkExports”设置为 org.apache.log4j 所以(我猜)使用了 tomcat log4j ...这不起作用,因为我的依赖项需要一些 slf4j 类它们作为 log4j 包的片段提供...现在已经不存在了...

当然我还有一个片段包,它使用 log4j.properties 文件扩展 log4j 包,但看起来这个 log4j 包是不曾用过。

添加:我应该补充一点,我正在 Eclipse 中开发应用程序...并且配置 log4j / slf4j 的片段包在那里工作。

有人解决这个问题了吗? 有任何想法吗?

When deploying my OSGi web application using the equinox servlet bridge i get the following:

log4j:WARN No appenders could be found for logger (org.springframework.osgi.extender.internal.activator.ContextLoaderListener).
log4j:WARN Please initialize the log4j system properly.

I tried several ways of supplying the necessary "log4j.properties" file, including:

  • adding the context-param "log4jConfigLocation" to the servlet bridge web.xml
  • creating a folder "classes" in the WEB-INF folder and copying my log4j.properties file there (and copying it in several other locations)
  • removing my log4j bundle and setting "extendedFrameworkExports" to org.apache.log4j so (I guess) the tomcat log4j is used ... this did not work because my dependencies need some slf4j classes which are provided as a fragment for the log4j bundle ... which isn't there anymore ...

Of course I also have a fragment bundle which extends the log4j bundle with a log4j.properties file, but it looks like this log4j bundle is not used.

ADDED: I should add that I'm developing the application in Eclipse... and my fragment bundle which configures log4j / slf4j works there.

Has anyone solved this? Any ideas?

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

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

发布评论

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

评论(3

二智少女猫性小仙女 2024-07-23 08:36:30

我发现了我的错误。 应该提供 log4j.properties 文件的片段不包含它,因为我没有将它添加到 build.properties 中的二进制构建中。

I found my error. The fragment which should provide the log4j.properties file did not include it, because I did not add it to the binary build in build.properties.

碍人泪离人颜 2024-07-23 08:36:30

我遇到了同样的问题,并将 log4j.properties 添加到我的 /src 文件夹中。

I had the same issue and I added log4j.properties to my /src folder.

時窥 2024-07-23 08:36:30

更新:这并不能真正解决你的问题......

我只是自己研究 OSGi。

不完全是您要寻找的内容,但以下 帖子 讨论了相同的内容使用普通春分时出现问题(即:不在 tomcat/jetty 中托管)。

它建议创建一个“片段包”(示例可供下载)来保存您的 log4j.properties。 也许你可以尝试类似的东西?

或者也许您只需将 log4j.properties 放入 WAR 的 META-INF 中?

UPDATE: This doesn't really help with your issue...

I am just researching OSGi myself.

Not quite what you're looking for, but the following post discusses the same issue when using vanilla equinox (ie: not hosted within tomcat/jetty).

It suggests creating a 'fragment bundle' (example available for download) to hold your log4j.properties. Perhaps you could try something similar?

Or perhaps you just need to place the log4j.properties inside META-INF of your WAR?

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