Today finally finished reading the log4j, the mood is good! Take out your own study notes and share them with us.

Source: Internet
Author: User
Note 1.log4j has three main components: logger, Appender and Layout2. LOG4J offers the following appender: Org.apache.log4j.ConsoleAppender (console) org.apache.log4j.FileAppender (file) Org.apache.log4j.DailyRollingFileAppender (generates a log file every day) Org.apache.log4j.RollingFileAppender (a new file is generated when the file size reaches a specified size) Org.apach E.log4j.writerappender (sending log information in streaming format to any specified place) 3.log4j provides the following layout: Org.apache.log4j.HTMLLayout (layout in HTML tabular form) Org.apache.log4j.PatternLayout (the flexibility to specify layout patterns) Org.apache.log4j.SimpleLayout (the level and information string that contains the log information) Org.apache.log4j.TTCCLayout (contains log Time, thread, category, etc information) 4. LOG4J provides several output formats:%m:used to output the method name where the logging request is issued.%m:used to output the application Su Pplied message associated with the logging event.%l:used to output location information of the caller which the Logging event%l:used to output the line number from where the logging request is issued.%p:used to output the priority of The logging event.%n:outputs the platform dependent line separator character or characters. %r:used to output the Nu Mber ofMilliseconds elapsed since the start of the application until creation of the logging to output the file Name where the logging request is issued.%d:used to output the date of the logging event. %c:used to output the cat Egory of the logging event%c:used to output the fully qualified class name of the caller issuing the logging. If the In the case of high efficiency requirements, the Log.debug () before the log.isdebugenabled () to judge, which can greatly reduce the execution time 6. For each appenders, Common properties are layout (typically set to Org.apache.log4j.PatternLayout), Threshold (log level) (1) Consoleappender:target ( System.out and System.err) (2) Fileappender:file (defines the file name of the output), Append (defined as append) ( 3 Dailyrollingfileappender (except Fileappender attribute): maxfilesize (maximum file size), Maxbackupindex ()


When necessary, you can refer to: http://dev.csdn.net/develop/article/62/62201.shtm


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.