Use of the Python logging module logging

Source: Internet
Author: User

The shell record log, eyeful flower of the redirect in line with, looked very uncomfortable there is no! I like Python, just like the feeling of buying a flashlight and a spare battery ready. Logging module is very simple, import module, define the log format. The log can be recorded in the Code through Logging.info (), logging.warning (), Logging.debug (). And immediately feel the whole person a lot better ...

Import Logginglogging.basicconfig (level=logging. DEBUG, format= '% (asctime) s% (filename) s[line:% (lineno) d]% (levelname) s% (message) s ', datefmt = '%a,%d%b%Y%h:%m:%s ', filename= ' MyLog.log ', filemode= ' a ') logging.info ("This is the logging module Recorded info ") Logging.debug (" This is the debug information for the Logging module ") logging.warning (" This is warning information for the logging module ")


The log output is as follows:
Thu, 17:24:43 1.py[line:12] Info This is the logging module recorded info
Thu, 17:24:43 1.py[line:13] Debug This is the debug information for the logging module
Thu, 17:24:43 1.py[line:14] WARNING This is logging information for the WARNING module

This article is from the "Candle Shadow Red" blog, be sure to keep this source http://gccmx.blog.51cto.com/479381/1612082

Use of the Python logging module logging

Related Article

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.