Python logging Quick Start

Source: Internet
Author: User

This article describes the rapid use of the logging module, If you need in-depth customization, please refer to (http://docs.python.org/2/howto/logging-cookbook.html)

 
Import logging. basicconfig (format = '[% (asctime) S]' + logging. basic_format) # logging. basic_format = "% (levelname) S: % (name) S: % (Message) s" log = logging. getlogger (_ name _) log. setlevel (logging. debug) log.info ('hahaha') >>> [13:24:23, 059] info :__ main __: haha

#3: logging. basicconfig () is a method used in the logging module of python to configure logging. However, there is no time in the format, so a new formatting method is passed in the basicconfig method.

#5: Default Format String

#7: Obtain the log of this module

#9: Set the Log Level

#10: Output log

#13: Output example

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.