Python--logging Log

Source: Internet
Author: User

For a very detailed log use please see here: http://www.cnblogs.com/dkblog/archive/2011/08/26/2155018.html

1 #Import Log Module2 ImportLogging3 #you need to import this module when setting up a log with a configuration file4 ImportLogging.config5 classMyLog:6     " "Log class for writing log information to a. txt file" "7     8     #load configuration information from Logging.cfg9     __loadcfg=logging.config.fileconfig ("Loggers/logging.ini")Ten  One     #gets a logger object that is the same log object when the log object is obtained elsewhere in the current program process by using the name parameter. A     __dblog=logging.getlogger ('DBLog') -  - @staticmethod the     defAddlog (msg,logrefname=None): -         " "//Add log - //1.msg: Log content - //2.logrefname: This name gets the log object, which is dblog by default. Other names to be viewed in the config file +         " " -         ifLogrefname is  notNone: +MyLog.__dblog=Logging.getlogger (logrefname) A          atMyLog.__dblog. Debug (msg)

Call Mylog.addlog (logmsg) to join the log when you use it.

Problems:
# 1. Error. Keyerror formatters is a path problem
# 2. Error GBK ... With VS2013, the new Python file is not utf-8 encoded and needs to be changed. But for this logging.ini, actually to change back to gb2312 (936). If you don't change it, you will report the mistake.

Python--logging Log

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.