In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
Python how to configure logging files, I believe that many inexperienced people do not know what to do, so this article summarizes the causes of the problem and solutions, through this article I hope you can solve this problem.
Logging.conf
[loggers] keys=root,cping, API [logger _ root] level=DEBUGhandlers= stream [logger _ cping] handlers=stream,filequalname=cpingpropagate= 0 [logger _ api] handlers=stream,filequalname=cpingpropagate=0## [handlers] keys=stream, file [handler _ stream] class=StreamHandlerlevel=INFOformatter=standardargs= (sys.stdout,) [handler_file] class=cping.utils.log_helper.MyLoggerHandlerlevel=INFOformatter=standardargs= ('logs/cping.log',' MONTH' 36) # # [formatters] keys= standard [formatter _ standard] format=% (asctime) s -% (name) s -% (levelname) s -% (message) sdatefmt=
Use
Import loggingimport logging.configlogging.config.fileConfig ('logging.conf') # create loggerlogger = logging.getLogger (' cping') # 'application' codelogger.debug (' debug message') logger.info ('info message') logger.warning (' warn message') logger.error ('error message') logger.critical (' critical message')
Note: root must be configured, otherwise an error will be reported
Logging.config.fileConfig ('logging.conf') File "/ usr/lib/python2.7/logging/config.py, line 86, in fileConfig _ install_loggers (cp, handlers, disable_existing_loggers) File" / usr/lib/python2.7/logging/config.py ", line 190, in _ install_loggers llist.remove (" root ") ValueError: list.remove (x): x not in list after reading the above, have you mastered how to configure logging files in python? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.