Use the background:
Apache log4j is a powerful log file that we need to know how our configuration files are loaded and how they are loaded when we use the IDE to configure log4j in the project.
Load Mode:
(1), automatically load the configuration file:
LOG4J will default to find the source folder's configuration file at startup, either Log4j.properties or Log4j.xml, which requires an explanation of the source folder, source folder is the directory where the source files are stored, and when the Java files in our src are compiled, we can put the log4j configuration file in src or create a new resource source folder.
(1), manually load the configuration file:
If we want to manually load the configuration file, in the specific Java class add a sentence is OK, propertyconfigurator.configure ("log4j.properties");
It is important to note that the default read is the path to the project root directory, log4j.properties need to be placed in the root directory.
How to load:
The above describes the two load mode, now we need to understand how these configuration files are loaded, which of course need to see log4j source, take log4j.properties This configuration file example.
When we configure the log isolation level at Log4j.properties: log4j.rootcategory=info,stdout,r,log4j needs to load our configuration file.
Set Debug Debug in Logmanager you know, in the Logmanager method, level is the load log4j.properties levels, which is the same as what we configured.