需要解决 Tomcat 在记录器被处置后尝试记录事件的 Web 应用程序错误

发布于 2024-09-14 13:59:46 字数 593 浏览 1 评论 0原文

环境:JSF 2.0、RichFaces 3.3.3、Facelets 1.1.15B1、Spring Framework 3.x、WebFlow 2.1、MyBatis 3.0.1、Oracle 10/11 g 后端、SLF4j 到 Log4j。好吧,这可能是 TMI,因为我的问题只是一个日志记录问题,但过于彻底总比不彻底好。

无论如何...我只是设置了 SLF4j & log4j 所以现在所有内部facelets日志消息都被转储到log4j & log4j中。我实际上可以看到他们。此外,我将 Tomcat 设置为也转储到 log4j,而不是 JULI 的自定义版本。执行此操作后,一切似乎都运行良好......直到我关闭应用程序。

在关闭过程的中途,我的应用程序开始左右抛出错误,因为(这是有道理的)Tomcat 正在尝试在 spring 已经清理了记录器 bean 之后获取记录器实例。

有人熟悉这个吗?我想这对于使用非标准日志记录机制的 Tomcat 的人来说一定是一个常见问题。解决这个问题的最佳方法是什么?

我想也许如果我只是提高日志级别,那么 Tomcat 甚至不会因为级别 req.s 而尝试记录消息,但是当 tomcat 尝试检索记录器实例时出现问题,因此这不起作用。

Enviroment: JSF 2.0, RichFaces 3.3.3, Facelets 1.1.15B1, Spring Framework 3.x, WebFlow 2.1, MyBatis 3.0.1, Oracle 10/11 g backend, SLF4j into Log4j. Well thats probably TMI since my issue is only a logging problem but better to be too thorough than not.

Anyways... I just setup SLF4j & log4j so now all of the internal facelets log msgs are being dumped into log4j & I can actually see them. In addition I setup Tomcat to also dump to log4j instead of it's custom version of JULI. Upon doing this everything appeared to be working great.... until i shut down the app.

Midway through the shutdown process my app started barfing up errors left 'n right because (which makes sense) Tomcat is trying to grab a logger instance AFTER spring has already cleaned up the logger bean.

Anyone familiar with this? I imagine it must be a common problem for anyone who has Tomcat using the non-standard logging mechanism. What is the best way around this?

I thought maybe if I just raised the log level then Tomcat wouldn't even try to log msgs because of the level req.s but the problem occurs when tomcat is trying to retrieve a logger instance so that didn't work.

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

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

发布评论

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

评论(1

笨死的猪 2024-09-21 13:59:46

我会将记录仪移到食物链的更高位置。

我个人从未使用 spring 配置 log4j,依赖于它自己的配置机制(并寻找它到底在哪里找到它在过程中使用的属性文件)。

如果可以的话,您可以选择从您的 war 中完全删除 log4j,并依赖于通用 tomcat 库类路径中的 log4j。当然,您会受到 tomcat 配置的支配,并且无法从应用程序内部访问日志,但它在应用程序的整个生命周期中始终存在。

I would move the Logger higher in the food chain.

I personally never configured log4j with spring relying on its own configuration mechanism (and hunting for where the heck it finds the properties file it is using in the process).

If you can you can opt to completely remove log4j from your war and rely on the log4j in the common tomcat library classpath. Then of course you are at the mercy of the tomcat configuration and you cannot access the log from inside your app, but it is always there during the complete lifecycle of your app.

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