Python logging module Basicconfig configuration file

Source: Internet
Author: User

Logging.basicconfig (level=log_level,                    format='% (asctime) s% (filename) s[line:% (Lineno) d ]% (levelname) s% (message) s',                    datefmt='%a,%d%b%Y%h:%m:%s' ,                    filename='parser_result.log',                    filemode= ' W ')
logging.basicconfig function Parameters: FileName: Specifies the log file name FileMode: The same as the file function, specify the open mode of the log files,'W'Or'a'Format : Specifies the formats and contents of the output, format can output a lot of useful information, as in the example above:%(Levelno) S: Print the value of the log level%(levelname) S: Print log level name% (pathname) s: Prints the path of the currently executing program, which is actually sys.argv[0] %(filename) S: Print the current name of the executing program%(funcName) s: Print the current function of the log%(Lineno) d: Print the current line number of the log%(asctime) s: Time to print the log%(thread) d: Print thread ID%(threadname) s: Print thread name%(process) d: Print process ID%(message) s: Print log information datefmt: Specifies the time format, same as Time.strftime () level: Sets the log levels by default to logging. Warningstream: Specifies the output stream that will log, can specify output to Sys.stderr, Sys.stdout or file, default output to Sys.stderr, when stream and filename are specified simultaneously, stream is ignored logging print information function: Logging.debug ('This is debug message') logging.Info('This is info message') logging.warning ('This is warning message')

Python logging module Basicconfig configuration file

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.