问题
The following are just a few samples of logging statements that come out on my Tomcat 7 console. Most are coming from open saml or hibernate and I'm trying to prevent them from coming out. I am using logback and have the root logger and all other loggers at WARN or above and I can't figure out why certain libraries continue to log out INFO and DEBUG level statements. Any ideas?
14:40:45.360 [localhost-startStop-6] DEBUG org.opensaml.xml.XMLConfigurator - {http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd}Username intialized and configuration cached
14:40:45.360 [localhost-startStop-6] DEBUG org.opensaml.xml.XMLConfigurator - Initializing object provider {http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd}UsernameToken
14:40:45.360 [localhost-startStop-6] DEBUG org.opensaml.xml.Configuration - Registering new builder, marshaller, and unmarshaller for {http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd}UsernameToken
14:40:45.361 [localhost-startStop-6] DEBUG org.opensaml.xml.XMLConfigurator - {http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd}UsernameToken intialized and configuration cached
14:40:45.361 [localhost-startStop-6] DEBUG org.opensaml.xml.XMLConfigurator - ObjectProviders load complete14:40:45.361 [localhost-startStop-6] DEBUG org.opensaml.xml.XMLConfigurator - Preparing to load IDAttributes
14:40:45.361 [localhost-startStop-6] DEBUG org.opensaml.xml.XMLConfigurator - IDAttribute {http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd}Id has been registered
14:40:45.361 [localhost-startStop-6] DEBUG org.opensaml.xml.XMLConfigurator - IDAttributes load complete
14:40:45.361 [localhost-startStop-6] DEBUG org.opensaml.DefaultBootstrap - Initializing SAML Artifact builder factories
回答1:
After looking for a solution off and on for months, I stumbled upon a related answer on this site:
logbback generating too many logs on Tomcat console at startup
回答2:
Took me hours to figure it out too, despite all above useful hyperlinks and references. My config is a Tomcat 7 instance running in TcServer launched from the Spring Tools Suite. However, the clue was given: logback was indeed (still) the culprit eventhough I had completely removed it from my maven dependency hierarchies in favor of pure log4j binding under slf4j (and of course no LogbackConfigListener left elsewhere I could figure)... but I forgot to force a maven clean and a copy of logback jar was still present in the target sub-directory from which the war archive was built. Suprinsingly enough, the presence of this logback jar in the war was sufficient to fool up server logging into DEBUG mode. Project clean - maven clean - rebuild, maven package again and then deploy: server logs now clean on the console and at last compliant to my src/main/resources/log4j.xml config, although I did not change a single log configuration file.
Extra tip to save extra time: while restating dependencies strictly on slf4j-log4j ensure you are using JRE1.6 or above with log4j version 1.2.17 and not 1.2.15 to avoid another string of problems regarding missing maven dependencies re jms, jdmk, and jmx... :-)
Reminder: to customize logging config for TcServer/tomcat launched from STS: http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=2009731
来源:https://stackoverflow.com/questions/20130574/tomcat-debug-logging-coming-out-on-console-unexpectedly