Tomcat6 ignores logging.properties partially

☆樱花仙子☆ 提交于 2019-12-11 04:07:18

问题


I'm using Tomcat 6, and this is my logging.properties:

handlers = org.apache.juli.FileHandler, java.util.logging.ConsoleHandler
.level=FINE

org.apache.catalina.core.ApplicationContext.level = OFF

org.apache.juli.FileHandler.level = ALL
org.apache.juli.FileHandler.directory = ${catalina.base}/logs
org.apache.juli.FileHandler.prefix = mylog.

java.util.logging.ConsoleHandler.level = FINE
java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter

On the one hand, Tomcat seems to read this file, as it correctly saves the logfiles with the prefix "mylog" and prints only messages with log-level FINE and above. On the other hand, it keeps on writing log messages like this:

Jun 8, 2010 9:53:30 PM org.apache.catalina.core.ApplicationContext log
SEVERE: Error writing messages
ClientAbortException:  java.net.SocketException: Broken pipe

I actually wanted to suppress all log messages from this class, as they flood my logfile, and the error is irrelevant for me. So why is the following line ignored?

org.apache.catalina.core.ApplicationContext.level = OFF

Is there any other way to suppress the log output of this class?


回答1:


org.apache.catalina.core.ApplicationContext is not the name of the logger used in ApplicationContext, it uses the log of a composite: the org.apache.catalina.core.StandardContext's log.

--edit: Maybe it's because they're context loggers. Then they need to be configured differently

something like

org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/manager].level = INFO
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/manager].handlers = \ 

I've not done that before, I've never used tomcat's logging facilities, and there is not much info to find




回答2:


I think Redlab's on the right track - notice that the root of the logger name is org.apache.catalina.core.ContainerBase, not org.apache.catalina.core.StandardContext. The method org.apache.catalina.core.ContainerBase.logName() controls the logger name and it explicitly starts with ContainerBase.class.getName(). Just to clarify, StandardContext extends ContainerBase.



来源:https://stackoverflow.com/questions/3001684/tomcat6-ignores-logging-properties-partially

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