SSH Log4j配置

SSH Log4j配置

==置web.xml==
	<!-- log4j监听 -->
	<listener>
		<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
	</listener>

	<!-- log4j -->
	<context-param>
		<param-name>log4jConfigLocation</param-name>
		<param-value>/WEB-INF/classes/conf/log4j.properties</param-value>
	</context-param>
	
==添加jar包==
	log4j-1.2.15.jar
	spring-web.jar
	
==配置log4j.properties==

#Config
log4j.debug=true
log4j.rootLogger=INFO,ERROR,CONSOLE,FILE
log4j.logger.org.springframework=error
log4j.logger.com.zte=debug

#Console appender 
log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
log4j.appender.CONSOLE.Threshold=info
log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
log4j.appender.CONSOLE.layout.ConversionPattern=[%d{yyyy-MM-dd HH:mm:ss}] %-5p %t %m (%F:%L)%n

#File appender
log4j.appender.FILE=org.apache.log4j.RollingFileAppender
log4j.appender.FILE.MaxFileSize=10MB
log4j.appender.FILE.MaxBackupIndex=10
log4j.appender.FILE.File=${catalina.base}/logs/ace_log.log
log4j.appender.FILE.Append=true
log4j.appender.FILE.layout=org.apache.log4j.PatternLayout
log4j.appender.FILE.layout.ConversionPattern=[%d{yyyy-MM-dd HH\:mm\:ss}] %-5p %t %m (%F\:%L)%n

==应用==
	private static final Log log = LogFactory.getLog(UserAction.class);

相关推荐