log4j.rootLogger = info, stdout, D, E, MAIL
Output to console
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.encoding=UTF-8log4j.appender.stdout.layout=org.apache.log4j.PatternLayout log4j.appender.stdout.layout.ConversionPattern= %d{ABSOLUTE} %5p %c{1}:%L - %m%n
log4j.appender.stdout.layout.ConversionPattern= %d{yyyy-MM-dd HH:mm:ss.SSS} %5p %c{1}:%L - %m%n
Copy the code
Output to a log file
log4j.appender.D=org.apache.log4j.RollingFileAppender
log4j.appender.D.File=${catalina.home}/logs/passport/passport.log
log4j.appender.D.Append=true
log4j.appender.D.encoding=UTF-8
log4j.appender.D.MaxFileSize=20MB
log4j.appender.D.MaxBackupIndex=3
log4j.appender.D.Threshold=INFO
log4j.appender.D.ImmediateFlush=true
log4j.appender.D.layout=org.apache.log4j.PatternLayout
log4j.appender.D.layout.ConversionPattern= %-d{yyyy-MM-dd HH:mm:ss.SSS} - [ %p ] %m%n
Copy the code
Save exception information to a separate file
log4j.appender.E=org.apache.log4j.DailyRollingFileAppender
log4j.appender.E.File=${catalina.home}/logs/passport/passport_error.log
log4j.appender.E.Append=true
log4j.appender.E.encoding=UTF-8
log4j.appender.E.Threshold=ERROR
log4j.appender.E.ImmediateFlush=true
log4j.appender.E.layout=org.apache.log4j.PatternLayout
log4j.appender.E.layout.ConversionPattern= %-d{yyyy-MM-dd HH:mm:ss.SSS} - [ %p ] %m%n
Copy the code
Email the error message to the appropriate person
Log4j's mail appender, If necessary you can write your own appender # log4j.appender.MAIL=org.apache.log4j.net.SMTPAppender Log4j. Appender. MAIL = com. XXX. Utils. Log4j. The threshold of the SMTPAppender # send MAIL, only when equal to or higher than the ERROR (such as FATAL), . Email was sent to log4j appenders. MAIL. Threshold = ERROR # cache file size, the log reaches 10 k send Email log4j. Appender. MAIL. BufferSize =500# SMTP email server address log4j. Appender. MAIL. SMTPHost = SMTP. Partner. The outlook.. Cn log4j appenders. MAIL. SslTrust = SMTP. Partner. Outlook. Cn log4j.appender.MAIL.starttlsEnable=truelog4j.appender.MAIL.Subject=[PASSPORT]-Log4J-ERROR OCCURED! . # SMTP to send certified account name log4j appenders. MAIL. SMTPUsername = MAIL@unisound#.com send SMTP authentication account password log4j. Appender. MAIL. Enb SMTPPassword = 4@wcnBU$k50mNLog4j.appender.mail. From= MAIL@unisound.com
log4j.appender.MAIL.To=libin@unisound.com
log4j.appender.MAIL.layout=org.apache.log4j.PatternLayout
log4j.appender.MAIL.layout.ConversionPattern= %d{yyyy-MM-dd HH:mm:ss.SSS} - [ %p ] %c{1}:%L - %m%n
Copy the code