SoFunction
Updated on 2024-12-13

Python3.6 Logging Logging module simple usage examples

This article example describes the simple usage of Python3.6 Logging Logging module. Shared for your reference, as follows:

Logging is a very handy module for printing logs

I'll just list one of the most flexible methods

# -*- coding:utf-8 -*-
#!python3
import logging
logger = () # logging objects
fh = ("") # Document objects
sh = () # Output stream objects
fm = ('%(asctime)s-%(filename)s[line%(lineno)d]-%(levelname)s-%(message)s') # Formatting objects
(fm) # Set the format
(fm) # Set the format
(fh) # logger add file output stream
(sh) # logger add standard output stream (std out)
() # Set the prompts to start at that level
("debug Test")
("info Test")
("warning Test")
("error Test")
("critical Test")

Run results:

Readers interested in more Python related content can check out this site's topic: theSummary of Python log manipulation techniques》、《Summary of Python function usage tips》、《Summary of Python string manipulation techniques》、《Python introductory and advanced classic tutorialsand theSummary of Python file and directory manipulation techniques

I hope that what I have said in this article will help you in Python programming.