The following is a brief discussion on the configuration file path of python logs. It has a good reference value and I hope it will be helpful to everyone. Let’s take a look together
As shown below:
import logging import logging.config logging.config.fileConfig(path) logger = logging.getLogger('')
Use the above python code When configuring log output, if the script is the main script (that is, it imports others, is not imported by others, and is at the top of the execution logic), the log configuration file represented by path can only be in the same directory as the script or in its subfolder. inside.
import sys sys.path.append('..')
Such code only works for import modules
Related recommendations:
Detailed explanation of python log printing And write the concurrent implementation code
##
The above is the detailed content of A brief discussion on the configuration file path problem of python logs. For more information, please follow other related articles on the PHP Chinese website!