Home  >  Article  >  Backend Development  >  A brief discussion on the configuration file path problem of python logs

A brief discussion on the configuration file path problem of python logs

不言
不言Original
2018-04-28 09:52:092989browse

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn