Spring、log4j 和 JBoss4

发布于 2024-07-25 10:05:51 字数 250 浏览 2 评论 0原文

我正在运行 JBoss 4.2.3.GA,并且有一个使用 Spring 和 Log4j 的 Web 应用程序。 我已经设置了 Spring 的 Log4jConfigurer,但是由于 JBoss 的 log4j 文件不在类路径上,所以遇到了问题。 它位于 jboss.home/server/default/conf/jboss-log4j.xml。 那么,如果不在 Log4jConfigurer 中硬编码路径,如何让 Spring 使用 JBoss 的 log4j 文件呢?

I'm running JBoss 4.2.3.GA, and have a web app that uses Spring and Log4j. I've set up Spring's Log4jConfigurer, but am having a problem since JBoss's log4j file is not on the classpath. It's at jboss.home/server/defaul/conf/jboss-log4j.xml. So, without hard-coding the path in Log4jConfigurer, how can I get Spring to use JBoss's log4j file?

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

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

发布评论

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

评论(2

那小子欠揍 2024-08-01 10:05:51

您通常不会通过应用程序修改 JBoss 的 log4j 配置,这是一条通往疯狂的道路。 JBoss 在所有应用程序之间使用共享配置。

但是,您可以以编程方式更改 log4j 的运行时配置,例如添加自定义附加程序或记录器。 然而,这不是 Spring 的 Log4jConfigurer 的用途 - 您可以使用它来配置独立的 log4j 配置。

You don't generally modify JBoss's log4j config via the applications, that's a route to madness. JBoss uses a shared configuration amongst all apps.

You can, however, programmatically alter log4j's runtime configuration, such as adding custom appenders or loggers. This isn't what Spring's Log4jConfigurer is for, however - you use that to configure a standalone log4j config.

楠木可依 2024-08-01 10:05:51

请回答您的问题:JBoss 通常会设置指向服务器目录和配置目录的附加系统属性。 您应该能够从您的应用程序访问这些或让它们从 spring 上下文中解析。

在您的情况下,应该可以访问 ${jboss.server.home.dir}/conf/jboss-log4j.xml

正如 skaffman 在评论中正确指出的那样,无需配置Spring 读取 JBoss 的 log4j 配置,除非您在打包中进行了其他修改。 您只需注意类路径根目录中没有 log4j.[properties,xml] ,或者组件尝试“手动”配置 Log4J 即可。

希望这能有所帮助,
卡里姆

Do answer your question: JBoss usually sets additional system properties that point to the server directory and configuration directories. You should be able to access these from your application or let them be resolved from the spring contexts.

In your case, it should be ok to access ${jboss.server.home.dir}/conf/jboss-log4j.xml

As skaffman correctly pointed out in a comment, there is no need to configure Spring to read JBoss' log4j configuration unless you have otherwise adapted something in the packaging. You will only have to take care that no log4j.[properties,xml] lies somewhere in the root of the classpath or that a component tries to configure Log4J "manually".

Hope this could help,
Kariem

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