Brief analysis of log4j source code | Reading configuration Files

Source: Internet
Author: User

Logmanager during initialization, reads the value of the log4j.configuration system variable, generates the URL of the configuration file, The default is Log4j.properties or Log4j.xml. Then use the Propertyconfigurator class to parse the Log4j.properties file.

Read the source to understand that the Propertyconfigurator class implemented the Configurator interface, overloaded the Configure method to read the properties file, and then through the overload Doconfigure method to assemble the logger properties.

The specific source code please refer to Log4j/logging-log4j-1.2.13/src/java/org/apache/log4j/propertyconfigurator.java.

The Log4j.xml file is parsed by the Domconfigurator.java class.

The specific source code refer to Log4j/logging-log4j-1.2.13/src/java/org/apache/log4j/xml/domconfigurator.java

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.