Python-several configuration methods of logging module

3 ways to configure logging:
  • 1) Use Python code to explicitly create loggers, handlers and formatters and call their configuration functions respectively;
  • 2) Create a log configuration file, and then use the fileConfig() function to read the contents of the file;
  • 3) Create a dict containing configuration information, and then pass it to the dictConfig() function;
It should be noted that logging.basicConfig() also belongs to the first method, it just encapsulates the configuration functions of loggers, handlers and formatters. In addition, the advantage of the second configuration method over the first configuration method is that it separates the configuration information and the code, which reduces the maintenance cost of the log, and also allows non-developers to easily Modify the log configuration.

Guess you like

Origin blog.csdn.net/zangba9624/article/details/108458547