Log processing-logging Module

Source: Internet
Author: User
Tags add time erro how to add time
1 log level: 2 'critical ': critical, 3 'error': error, 4 'warn': warning, 5 'warning': warning, 6 'info': info, 7 'debug': Debug, 8 'notset': notset,
Import logginglogging. warning ("User [WY] attempted wrong password more than 3 times") logging. critical ("server is down") Output: Warning: Root: User [WY] attempted wrong password more than 3 timescritical: Root: Server is down how to write logs to files? Import logginglogging. basicconfig (filename = "example. log ", level = logging. info) # The filename is followed by the log file name and the level is info. The log file records logging logs at or above the info level. warning ("User [WY] attempted wrong password more than 3 times") logging.info ("show this") logging. debug ("this is erro") logging. critical ("server is down") generates a new file example. logexample. log Record: Warning: Root: User [WY] attempted wrong password more than 3 timesinfo: Root: Show thiscritical: Root: Server is down Log Level: Debug <info <warning <critical

 

1 how to add time to logs? 2 Import logging 3 logging. basicconfig (filename = "example. log ", level = logging. info, format = "% (asctime) S % (Message) s", datefmt = "% m/% d/% Y % I: % m: % S % P ") # Note: Case Sensitive 4 logging. warning ("User [WY] attempted wrong password more than 3 times") 5 logging.info ("show this") 6 logging. debug ("this is erro") 7 logging. critical ("server is down") 8 9 example. log display: 10 10/20/2016 08:49:32 PM user [WY] attempted wrong password more than 3 times11 10/20/2016 08:49:32 PM show this12 10/20/2016 08:49:32 PM server is down

 

Log processing-logging Module

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.