【背景】
看到:
所以去试试,看看能否实现,对于python的logging,使得不输出信息到对应的windows的cmd中。
此处,假设需求是:
只输出内容到文件中,但是不显示到windows的cmd中。
【解决过程】
1.参考这里:
去写测试代码。
经过一番折腾,代码如下:#!/usr/bin/python
# -*- coding: utf-8 -*-
"""
Function:
【已解决】使Python中的logging的日志内容不输出到(Windows的cmd,Linux的terminal等)终端中
https://www.crifan.com/python_logging_not_ouput_info_to_command_line_or_terminal
Author: Crifan Li
Time: 2013-01-30
"""
#---------------------------------import---------------------------------------
import logging;
#------------------------------------------------------------------------------
def main():
logging.info("logging.info: This is logging example, current file log level is logging.DEBUG");
logging.debug("logging.debug: you should not see this line in log file, for current file log level to logging.DEBUG");
logging.warning("logging.warning: you can see this line in log file , for current file log level to logging.DEBUG, and logging.warning is above logging.DEBUG");
logging.error("logging.error: you can see this line in log file , for current file log level to lo