The most comprehensive log framework arrangement in history

1) First, we call the getLogger method to get a Logger, which is overloaded for two methods:

2) However, all roads lead to the same goal. Both overloaded methods call demandLogger (Name, ResourceBundlename, Caller Class). Let's take a look at the contents of the Demand Logger method under Logger:

3) All roads lead to the same goal. By tracing the source code, we found that demandSystemLogger () finally called demandLogger (), so we only need to see how demandLogger () is implemented:

4) So far, we have learned how to get the logger object of, and then we have some logger configurations to override some default configurations in logging.properties mentioned above.

5) The next step is to formally output the log information:

6) Take log(level, msg, params) as an example to see how to output log information:

7) After that, we initially configured FileHandler and other custom handlers or default handlers to format log records, print and output to files.

8) Execution of the handler

9) Therefore, the Handler is executed during the process of calling publish. Finally, to sum up:

1) custom log format

2) Modify the configuration file

3) Call log in multithreading environment

4) output the result.