Reload tomcat logging at runtime?

给你一囗甜甜゛ 提交于 2019-12-02 06:45:39

I found one solution to this. Replacing the log manager in the startup script with the default java.util.logging.LogManager or simply deleting the command line argument results in the regular LogManager being used. This LogManager will fully reload the configuration for all Loggers in all ClassLoaders when readConfiguration() is called, exactly the behavior I need.

This does involve modifying the tomcat startup scripts, however. If someone can find a better solution without doing that, that would be great, otherwise I'll accept this answer.

Adam Gent

If your not married to Tomcat JULI you might want to consider using Logback since IMHO its the only the that reliably handles log configuration reloading during runtime.

I haven't done this myself but some one has written a guide: Logging with SLF4J and Logback in Tomcat and TomEE which basically using a bunch of bridge jars.

The other thing you might consider is just using per web app logging with Logback and just ignore Tomcat's JULI logs (thats what I do).

CAVEAT: http://www.slf4j.org/legacy.html#jul-to-slf4j ... consequently please never use JUL directly.... Guava and Tomcat are on my $hit list for using JUL.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!