Python #logging

Source: Internet
Author: User

###

#-*-Coding:utf-8-*-
Import logging
Import Logging.handlers
#Log DirectoryLog_file ='Log.zk'log_fmt='% (asctime) s-% (filename) s-% (levelname) s-% (message) s'date_fmt='%a,%d%b%Y%h:%m:%s'#The format of the instantiated FORMATTER,DATEFMT is formatted using Yime.strftime (format[, T])Formatter=logging. Formatter (fmt=log_fmt,datefmt=date_fmt)#Thu, Sep 10:46:29-log.py-error-the ERROR MESSAGE#Create a handler processorHandler =Logging.handlers.RotatingFileHandler (log_file)#add a log format to handlerHandler.setformatter (Formatter)#Create a Logger instanceLogger = Logging.getlogger ('Log.zk')#Setting the log levelLogger.setlevel (logging. ERROR)#Add a processorLogger.addhandler (handler) Logger.debug ('The DEBUG MESSAGE') Logger.info ('The INFO MESSAGE') logger.warning ('The WARN MESSAGE') Logger.error ('The ERROR MESSAGE') logger.critical ('The critical MESSAGE')

###

#-*-Coding:utf-8-*-
Import logging
Import Logging.handlers
#FileName: Log name, Level log class (logs with output info above include info)Logging.basicconfig (filename='Log.kafka', level=logging.info,format='% (asctime) s-% (filename) s-% (levelname) s-% (message) s') Logging.debug ('The DEBUG MESSAGE') Logging.info ('The INFO MESSAGE') logging.warning ('The WARN MESSAGE') Logging.error ('The ERROR MESSAGE') logging.critical ('The critical MESSAGE')

###

Reference blog:

http://blog.csdn.net/zyz511919766/article/details/25136485

Python #logging

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.