Log4j打印日志

一、所需jar包


二、log4j.properties

log4j.rootCategory=INFO,console,F
#log4j.rootCategory=ERROR,console,file

# A1 is set to be a LF5Appender which outputs to a swing
# logging console.

log4j.appender.F=org.apache.log4j.DailyRollingFileAppender 
log4j.appender.F.File=${catalina.home}/logs/serviceForPAD.log
#log4j.appender.F.MaxFileSize=500MB
#log4j.appender.F.MaxBackupIndex=30
log4j.appender.F.layout=org.apache.log4j.PatternLayout
log4j.appender.F.layout.ConversionPattern=[%-5p] %d{yyyy-MM-dd HH:mm:ss,SSS} method:%l%n%m%n
log4j.logger.org.apache=ERROR

# using console to Appender

log4j.appender.console=org.apache.log4j.ConsoleAppender
log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.layout.ConversionPattern=%d [%t] %-5p %c %x - %m%n

log4j.logger.java.sql.Connection=ERROR
log4j.logger.java.sql.Statement=ERROR
log4j.logger.java.sql.PreparedStatement=ERROR
log4j.logger.java.sql.ResultSet=ERROR 
log4j.logger.com.opensymphony.oscache=ERROR


你可能感兴趣的:(Log4j打印日志)