简体   繁体   English

是否可以覆盖Glassfish v3的默认日志记录?

[英]Is it possible to override the default logging for Glassfish v3?

Related to this question . 这个问题有关 It appears that Glassfish is exporting slf4j into my application and overriding my logging solution. 看来Glassfish正在将slf4j导出到我的应用程序中并覆盖了我的日志记录解决方案。 Is it possible for me to override Glassfish's logging and have my own logging solution take precedence? 我是否可以覆盖Glassfish的日志记录,并优先考虑自己的日志记录解决方案? After searching, I have only found ways to modify the log using logging.properties. 搜索之后,我仅找到了使用logging.properties修改日志的方法。

I am not married to my current implementation, but I am interested in making it work. 我不喜欢当前的实现方式,但是对使它起作用很感兴趣。

thanks. 谢谢。

As suggested in the other answer , try to configure GlassFish to use firstly the child classloaders before to delegate. 另一个答案中所建议,请尝试将GlassFish配置为在委托之前首先使用子类加载器。 In the sun-web.xml : sun-web.xml

 
 
 
  
  <sun-web-app> <class-loader delegate="false"/> </sun-web-app>
 
  

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). 但是,如果这行得通,那就是一个比实际解决方案更多的解决方法 ,您的应用程序不应受到bean-validation.jarweld-osgi-bundle.jar的SLF4J绑定的污染(至少相信如此)。 You should maybe raise an issue . 您也许应该提出一个问题

Update: For the archives, the suggested workaround doesn't work. 更新:对于存档,建议的解决方法不起作用。 But I couldn't reproduce the issue . 但是我无法重现这个问题

The short answer is, Glassfish does some nasty logger tweaking, redirecting System.out and System.err to its own log. 简短的答案是,Glassfish进行了一些讨厌的记录器调整,将System.out和System.err重定向到其自己的日志。 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. 我没有设法阻止它这样做,但是我找到了一种方法,可以通过尽早将slf4j库放置在类路径中并编辑Glassfish的logging.properties来在单个slf4j日志中收集所有服务器和应用程序日志消息。

For the long answer, see this blog post . 对于长答案,请参阅此博客文章

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM