是否可以覆盖 Glassfish v3 的默认日志记录?
与此问题相关。看来 Glassfish 正在将 slf4j 导出到我的应用程序中并覆盖我的日志记录解决方案。我是否可以覆盖 Glassfish 的日志记录并优先使用我自己的日志记录解决方案?经过搜索,我只找到了使用logging.properties修改日志的方法。
我并没有接受当前的实现,但我有兴趣让它发挥作用。
谢谢。
Related to this question. It appears that Glassfish is exporting slf4j into my application and overriding my logging solution. Is it possible for me to override Glassfish's logging and have my own logging solution take precedence? After searching, I have only found ways to modify the log using logging.properties.
I am not married to my current implementation, but I am interested in making it work.
thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
按照另一个答案中的建议,尝试配置 GlassFish 以使用首先是委托之前的子类加载器。在sun-web.xml
中:但是如果这有效,这更像是一个真正的解决方案的解决方法,您的应用程序不应该被bean-validation.jar 和 weld-osgi-bundle.jar 的 SLF4J 绑定(至少我相信是这样)。您也许应该提出问题。更新:对于存档,建议的解决方法不起作用。但是我无法重现该问题。
As suggested in the other answer, try to configure GlassFish to use firstly the child classloaders before to delegate. In thesun-web.xml
:But if this works, this is more a workaround that a real solution, your application shouldn't be polluted by the SLF4J bindings of bean-validation.jar and weld-osgi-bundle.jar (at least I believe so). You should maybe raise an issue.Update: For the archives, the suggested workaround doesn't work. But I couldn't reproduce the issue.
简短的回答是,Glassfish 做了一些令人讨厌的记录器调整,将 System.out 和 System.err 重定向到它自己的日志。我没有设法阻止它这样做,但我找到了一种方法,通过将 slf4j 库尽早放置在类路径中并编辑 Glassfish 的logging.properties,将所有服务器和应用程序日志消息收集在单个 slf4j 日志中。
有关详细答案,请参阅此博文。
The short answer is, Glassfish does some nasty logger tweaking, redirecting System.out and System.err to its own log. I did not manage to stop it doing so, but I found a way to collect all server and application log messages in a single slf4j log by placing the slf4j libs early enough in the classpath and editing the logging.properties of Glassfish.
For the long answer, see this blog post.