Reload tomcat logging at runtime?

前端 未结 2 502
名媛妹妹
名媛妹妹 2021-01-24 07:45

We are currently using Tomcat 7 with a single log configuration specified using -Djava.util.logging.config.file and the default ClassLoaderLogManager with -Djava.util.logging.ma

相关标签:
2条回答
  • 2021-01-24 08:26

    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.

    0 讨论(0)
  • 2021-01-24 08:27

    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.

    0 讨论(0)
提交回复
热议问题