Log4j's configuration is simple to make it over more and more applications: log4j configuration files implements full set of functions such as output to console, file, rollback file, send log mail, output to database log table, custom label, etc. .
It is enough to use it, log4j.rootlogger = debug, console, a1, im log4j.addivity.org.apache = true # is applied to the console log4j.rapnder.console = org.apache.log4j.consoleAppender log4j. appender.Threshold = DEBUG log4j.appender.CONSOLE.Target = System.out log4j.appender.CONSOLE.layout = org.apache.log4j.PatternLayout log4j.appender.CONSOLE.layout.ConversionPattern = [framework]% d -% c - % -4R [% T]%-5p% C% X-% M% N # log4j.Appender.console.Layout.conversionPattern = [start]% d {date} [date]% n% p [priority]% N % x [NDC]% N% T [Thread] N% C [category]% N% M [Message]% N% N # is applied to file log4j.Appender.file = org.apache.log4j.fileappender log4j.Appender. File.file = file.log log4j.Appender.File.Append = false log4j.Appender.File.Layout = Org.Apache.log4j.patternLayout log4j.Appender.File.Layout.conversionPattern = [framework]% D -% C - % -4R [% T]% -5p% C% X -% M% N # use this layout for logfactor 5 analyysis # is applied to file rollback log4j.Appender.rolling_file = org.apache.log4j.rollingFileAppender log4j.Appender. Rolling_file.threshold = error log4j.Appender.rolling_file.file = rolling.log log4j .appender.ROLLING_FILE.Append = true log4j.appender.ROLLING_FILE.MaxFileSize = 10KB log4j.appender.ROLLING_FILE.MaxBackupIndex = 1 log4j.appender.ROLLING_FILE.layout = org.apache.log4j.PatternLayout log4j.appender.ROLLING_FILE.layout.ConversionPattern = [Framework]% D -% C -% - 4R [% T]% -5p% C% X-% M% N # is applied to socket log4j.appender.socket = org.apache.log4j.rollingfileappender log4j.Appender. SOCKET.RemoteHost = localhost log4j.appender.SOCKET.Port = 5001 log4j.appender.SOCKET.LocationInfo = true # Set up for Log facter 5 log4j.appender.SOCKET.layout = org.apache.log4j.PatternLayout log4j.appender.SOCET . retiOout.conversionPattern =
[START]% D {Date} [DATE]% N% P [priority]% N% x [NDC]% N% T [thread]% N% C [category]% N% M [Message]% N% N # log Factor 5 Appender log4j.appender.LF5_APPENDER = org.apache.log4j.lf5.LF5Appender log4j.appender.LF5_APPENDER.MaxNumberOfRecords = 2000 # send logs to email log4j.appender.MAIL = org.apache.log4j.net.SMTPAppender log4j .appender.mail.threshold = Fatal log4j.Appender.mail.buffersize = 10 log4j.Appender.mail.from=web@www.wuset.com log4j.appender.mail.smtphost = www.wusetu.com log4j.Appender.mail .Subject = Log4J Message log4j.appender.MAIL.To=web@www.wusetu.com log4j.appender.MAIL.layout = org.apache.log4j.PatternLayout log4j.appender.MAIL.layout.ConversionPattern = [framework]% d -% C -% - 4R [% T]% -5p% C% x -% M% N # for database log4j.Appender.Database = org.apache.log4j.jdbc.jdbcappender log4j.Appender.Database.URL = jdbc: mysql: // localhost: 3306 / test log4j.appender.DATABASE.driver = com.mysql.jdbc.Driver log4j.appender.DATABASE.user = root log4j.appender.DATABASE.password = log4j.appender.DATABASE.sql = INSERT INTO LOG4J (Message) VALUES ('[FRA) MEWORK]% D -% C -% - 4R [% T]% -5p% C% X -% M% N ') log4j.Appender.Database.Layout = org.apache.log4j.patternlayout log4j.Appender.Database. Layout.conversionPattern = [framework]% D -% C -% - 4R [% T]% -5p% C% X-% M% N log4j.Appender.a1 = org.apache.log4j.dailyrollingFileAppender log4j.Appender.a1 .File = SampleMessages.log4j log4j.appender.A1.DatePattern = yyyyMMdd-HH'.log4j 'log4j.appender.A1.layout org.apache.log4j.xml.XMLLayout # custom Appender log4j.appender.im = net =. Cybercorlin.util.logger.Appender.imappender log4j.cybercorlin.host = mail.cybercorlin.Net log4j.cybercorlin.userName = username log4j.Appender.im.password =