log4j.rootCategory=INFO, stdout , R log4j.appender.stdout=org.apache.log4j.ConsoleAppender log4j.appender.stdout.layout=org.apache.log4j.PatternLayout log4j.appender.stdout.layout.ConversionPattern=[QC] %p [%t] %C.%M(%L) | %m%n log4j.appender.R=org.apache.log4j.DailyRollingFileAppender log4j.appender.R.File=D:\\Tomcat 5.5\\logs\\qc.log log4j.appender.R.layout=org.apache.log4j.PatternLayout 1log4j.appender.R.layout.ConversionPattern=%d-[TS] %p %t %c - %m%n log4j.logger.com.neusoft=DEBUG log4j.logger.com.opensymphony.oscache=ERROR log4j.logger.net.sf.navigator=ERROR log4j.logger.org.apache.commons=ERROR log4j.logger.org.apache.struts=WARN log4j.logger.org.displaytag=ERROR log4j.logger.org.springframework=DEBUG log4j.logger.com.ibatis.db=WARN log4j.logger.org.apache.velocity=FATAL log4j.logger.com.canoo.webtest=WARN log4j.logger.org.hibernate.ps.PreparedStatementCache=WARN log4j.logger.org.hibernate=DEBUG log4j.logger.org.logicalcobwebs=WARN log4j.rootCategory=INFO, stdout , Rlog4j.appender.stdout=org.apache.log4j.ConsoleAppenderlog4j.appender.stdout.layout=org.apache.log4j.PatternLayoutlog4j.appender.stdout.layout.ConversionPattern=[QC] %p [%t] %C.%M(%L) | %m%n log4j.appender.R=org.apache.log4j.DailyRollingFileAppenderlog4j.appender.R.File=D:\\Tomcat 5.5\\logs\\qc.loglog4j.appender.R.layout=org.apache.log4j.PatternLayout1log4j.appender.R.layout.ConversionPattern=%d-[TS] %p %t %c - %m%nlog4j.logger.com.neusoft=DEBUGlog4j.logger.com.opensymphony.oscache=ERRORlog4j.logger.net.sf.navigator=ERRORlog4j.logger.org.apache.commons=ERRORlog4j.logger.org.apache.struts=WARNlog4j.logger.org.displaytag=ERRORlog4j.logger.org.springframework=DEBUGlog4j.logger.com.ibatis.db=WARNlog4j.logger.org.apache.velocity=FATALlog4j.logger.com.canoo.webtest=WARNlog4j.logger.org.hibernate.ps.PreparedStatementCache=WARNlog4j.logger.org.hibernate=DEBUGlog4j.logger.org.logicalcobwebs=WARN
The configuration file of og4j is used to set the recorder level, storage device, and layout. It can be connected to the Key = value format setting or XML format setting information. Through configuration, you can create a log4j runtime environment. 1. the basic format of the configuration file log4j is as follows: # configure root loggerlog4j. rootlogger = [level], appendername1, appendername2 ,... # Configure the log output destination appenderlog4j. appender. appendername = fully. Qualified. Name. Of. appender. Class log4j. appender. appendername. option1 = value1... Log4j. appender. appendername. optionn = valuen # configure the log information format (layout) log4j. appender. appendername. layout = fully. qualified. name. of. layout. class log4j. appender. appendername. layout. option1 = value1... Log4j. appender. appendername. layout. optionn = valuen where [level] is the log output level. There are 5 levels in total: Fatal 0 error 3 warn 4 INFO 6 debug 7 appender is the log output destination, and log4j provides the following types of appender: org. apache. log4j. consoleappender (console), org. apache. log4j. fileappender (file), org. apache. log4j. dailyrollingfileappender (a log file is generated every day), org. apache. log4j. rollingfileappender (a new file is generated when the file size reaches the specified size), org. apache. log4j. writerappender (send log information to any specified place in the stream format) Layout: Log Output format. The layout provided by log4j includes the following types: Org. apache. log4j. htmllayout (layout in HTML form), org. apache. log4j. patternlayout (you can flexibly specify the layout mode), org. apache. log4j. simplelayout (Level and information string containing log information), org. apache. log4j. ttcclayout (including the log generation time, thread, category, and other information) Printing parameters: log4j uses a print format similar to the printf function in C language to format the log information, as shown below: % m the output priority of the specified message % P in the output code, that is, debug, info, warn, error, fatal % R: The number of milliseconds that the application started to output the log information % C the category of the output, this is usually the full name of the Class % T. The thread name % N that outputs the log event will output a carriage return line break. For Windows, the value is "\ r \ n" and Uni X platform is the date or time when "\ n" % d outputs the log time point. The default format is iso8601. You can also specify the format after it, for example: % d {YYY Mmm dd hh: mm: SS, SSS}, output is similar to: October 18, 2002 22: 10: 28,921% l location of the output log event, including category name, thread, and the number of lines in the code. Example: testlog4.main (testlog4.java: 10)
Address: http://summerbell.iteye.com/blog/487736
Http://www.blogjava.net/alexprefect/articles/372959.html