struts2+spring2.5+hibernate例子log4j无效
我做了小例子struts2+spring2.5+hibernate,当我部属到tomcat上服务启动时打出了如下的信息
信息: Initializing Spring root WebApplicationContext
10:19:14.625 [main] INFO o.s.web.context.ContextLoader - Root WebApplicationContext: initialization started
10:19:15.171 [main] INFO o.s.w.c.s.XmlWebApplicationContext - Refreshing org.springframework.web.context.support.XmlWebApplicationContext@1bbbafc: display name [Root WebApplicationContext]; startup date [Sun Aug 24 10:19:15 CST 2008]; root of context hierarchy
10:19:16.031 [main] DEBUG o.s.c.i.s.PathMatchingResourcePatternResolver - Looking for matching resources in directory tree [E:\MyEclipse 6.0.1\workspace\.metadata\.plugins\com.genuitec.eclipse.easie.tomcat.myeclipse\tomcat\webapps\sj\WEB-INF\classes]
10:19:16.031 [main] DEBUG o.s.c.i.s.PathMatchingResourcePatternResolver - Searching directory [E:\MyEclipse 6.0.1\workspace\.metadata\.plugins\com.genuitec.eclipse.easie.tomcat.myeclipse\tomcat\webapps\sj\WEB-INF\classes] for files matching pattern [E:/MyEclipse 6.0.1/workspace/.metadata/.plugins/com.genuitec.eclipse.easie.tomcat.myeclipse/tomcat/webapps/sj/WEB-INF/classes/applicationContext*.xml]
10:19:17.734 [main] DEBUG o.s.b.f.x.BeanDefinitionParserDelegate - Neither XML 'id' nor 'name' specified - using generated bean name [org.springframework.beans.factory.annotation.RequiredAnnotationBeanPostProcessor#0]
10:19:17.734 [main] DEBUG o.s.b.f.xml.XmlBeanDefinitionReader - Loaded 9 bean definitions from location pattern [classpath:applicationContext*.xml]
10:19:17.734 [main] INFO o.s.w.c.s.XmlWebApplicationContext - Bean factory for application context [org.springframework.web.context.support.XmlWebApplicationContext@1bbbafc]: org.springframework.beans.factory.support.DefaultListableBeanFactory@f6398
10:19:17.734 [main] DEBUG o.s.w.c.s.XmlWebApplicationContext - 9 beans defined in org.springframework.web.context.support.XmlWebApplicationContext@1bbbafc: display name [Root WebApplicationContext]; startup date [Sun Aug 24 10:19:15 CST 2008]; root of context hierarchy
如下等日志信息,
我不想它输出这么多的信息,想用log4j为日志输出,我把log4j.properties文件放在了classpath下,工程的lib下也有log4j-1.2.14.jar的包,可是log4j好像没起到作用,请问为什么啊,log4j.properties的文件配置没有问题
------解决方案--------------------log4j.rootLogger=ERROR, stdout ,logfile
#log4j.rootLogger=INFO, stdout ,logfile
#log4j.rootLogger=DEBUG, stdout ,logfile
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern= >>>>>>>日志<<<<<<< %r %d [%t] %-p %c %x - #%l# - %m%n
log4j.appender.logfile=org.apache.log4j.RollingFileAppender
log4j.appender.logfile.File=complaints.log
log4j.appender.logfile.MaxFileSize=2048KB
log4j.appender.logfile.layout=org.apache.log4j.PatternLayout
log4j.appender.logfile.layout.ConversionPattern= >>>>>>>日志<<<<<<< %r %d %p [%c] - %m%n
给个给你参考
------解决方案--------------------web.xml里加入以下配置:
XML code
<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>/WEB-INF/classes/log4j.properties</param-value>
</context-param>
<!-- Listener log4jConfigLocation -->
<listener>
<listener-class>
org.springframework.web.util.Log4jConfigListener
</listener-class>
</listener>