This chapter describes the Python built-in module: The log module, for more information, refer to: Python Learning Guide
Simple to useIn the beginning, we experienced the basic function of logging with the shortest code.import= logging.getLogger()logging.basicConfig()logger.setLevel('DEBUG')logger.debug('logsomething')#输出out>>DEBG:root:logsomething
The first step is to get a Loger object by using the Logging.getlogger function, but this
#coding: Utf-8import loggingclass Testlog (object): ' Logging ' def __init__ after encapsulation (self, logger = None): ' "Specifies the file path to save the log, the log level, and the call file to deposit the log into the specified file ' # ' creates a logger Self.logger = logging. GetLogger (Logger) self.logger.setLevel (logging. DEBUG) # Create a handler for
Original Reference ? http://msdn.microsoft.com/en-us/library/dn440731 (v=pandp.60). aspxFirst, Introductionlogs typically meet the two main requirements : 1 , monitor application performance, and provide information. In terms of performance, logs can monitor what's going on inside the program and sometimes monitor what's going on outside the program. 2. More importantly, it is used for auditing. This log tracks the user's behavior and records a series of tasks, read and modified information, an
Five levels of logging modeDebug details, which are typically interesting when debugging a problem. INFO proves that things work as expected. WARNING indicates that there have been some surprises, or that problems will occur in the near future (such as ' Disk full '). The software is still working properly. ERROR because of a more serious problem, the software is unable to perform some functions. CRITICAL A
Import Logging ''' Log Level: critical> error> warning> info> Debug. The higher the notset level, the fewer logs are printed, and vice versa. That is, debug: prints all logs (notset is equivalent to debug) info: print info, warning, error, and critical-level logs warning: Print warning, error, and critical-level log error: print error, critical-level log critical: print the critical-level log ''' Handler = Lo
There is a log in front of a simple introduction of log4j, but also introduced its relationship with commons-logging, but suddenly came out of a slf4j, and SLF4J has replaced the commons-logging trend, so, We can infer that the role of SLF4J and commons-logging shouldThere is little difference. OK, let's start with slf4j.1.slf4jHe only provides a core SLF4J API (
The two methods output by using the python logging module in stdout are described in detail.
Use the logging module of python to output data in stdout
Preface:
When using the python logging module, in addition to logging logs in files, you also want to directly output logs to the standard output std. out when runnin
For python, two problems have plagued me over the past few days:1. The current row number and function name cannot be obtained directly in python. This is a question raised by someone in the forum. the people below are just wondering why python does not provide _ line _ and _ func __like _ file __, however, no solution was found.2. How can a function call itself recursively without knowing its name. A colleague of mine asked me this question. In fact, I also obtained the function name, but I cou
Python logging library usage summary, pythonlogging
Preface
Recently, due to work requirements, it is very low to write some python scripts and print is always used to print information. So I took the time to study the python logging library, let's print and record the logs elegantly. Let's talk a little more about it. Let's take a look at the detailed introduction.
1. Simply print logs to the screen:
impor
Many programs have logging requirements, and the log contains information that has normal program access logs, there may be errors, warnings and other information output, Python's logging module provides a standard log interface, you can store various formats of the log, logging log can be divided into debug(),,, info() warning() and error() critical()5个级别, below
and 97-122 returns 26 lowercase letters. Instead, Ord (' a ') returns the corresponding number of the letter A in ASCII"""7temp = Chr (Random.randint (65,90))8 Else:9temp = Random.randint (0,9)TenCheckcode + =Str (temp) One Print(Checkcode)Logging Module (supplemental)There are 6 levels of logs, from high to low as follows:CRITICAL = 50FATAL = CRITICALERROR = 40WARNING = 30WARN = WARNINGINFO = 20DEBUG = 10NOTSET = 01, by default, Longging will on
Logging module for writing log filesThere are 5 levels, debug (), info (), warning (), error (), and Critical (), the highest level is critical ()Debug () debug mode, info () is the normal information, warning () is warning, error () is wrong, critical () is a serious issueNormal printing#-*-Coding:utf-8-*-__author__ = "MuT6 sch01ar" Import logginglogging.debug (' the Debug ') Logging.info (' the info ') Logging.warning (' Request outtime ') logging.e
Use Python logging to record log information such as DebugDebug above information written to fileInfo above info output in consoleImport Osimport loggingvde_logging_name = "vde_logging" Log_file_path = Os.path.join (Os.path.dirname (__file__), "Vde_ Regression.log ") def logger_initialization (): # 1. Logging logger = Logging.getlogger (vde_logging_name) logger.setlevel (
Day6 subprocess module, logging module, day6subprocess
Logging Module
Many programs need to record logs, and the information contained in the logs has normal program access logs, and may also have errors, warnings, and other information output, the python logging module provides standard log interfaces. You can store logs in various formats.debug(),info(),warning
BackgroundAs the open source framework is becoming richer, many of the log components used by open source frameworks are different. exist in a project, different versions, different frameworks coexist. Causes the log output to be unusually chaotic. Although it does not cause fatal damage to the system, it is clear that the architecture is not sophisticated enough and the pursuit of the ultimate is slightly inadequate.There are some standard common interface, standard implementation, the existenc
One of the most recent Web projects to use is the log, but it's not very understandable to the usual logging tools (frameworks), Mark.1.commons-logging.jar common-logging is a common log interface provided by Apache. The user is free to choose the third party's log component as a concrete implementation, like log4j, or the logging that comes with the JDK, common
Windows Installer can use logging to help solve problems encountered during installation of software packages. Enable this logging by adding an entry and a value to the Registry. After you add and enable an item, you can retry the problematic installation. The Windows Installer tracks the installation progress and sends the progress to the temp folder. The new log file name is random, but starts with the le
When a DML error is found in a recent project, it takes about one minute to process more than one thousand pieces of data one by one from a temporary table insert to a formal table. The performance is quite low,
The DML error logging in Oracle 10 Gb has outstanding performance in handling DML exceptions. I originally intended to write an article about this feature. There is just a classic chapter.
Home reference, there are not perfect, please make a b
1.logging ModuleThe logging module is the log module used to record the state of the program's operation.There are five levels:
Debug
Info
Warning
Error
Critical
Logging.debug ('Debug Message') #logging. info ('Info Message') logging.warning ('warn message') #表明发生了一些意外, or problems will occur in the near future (such as ' Disk full
Logging module
1. List all status and print to terminal.ImportLogginglogging.debug ("Test Debug")#debugging, error-removingLogging.info ("Test")#Informationlogging.warning ("user [Xsk] 3")#WarningLogging.error ("Test Error")#Errorlogging.critical ("Server is down")#SeriousNote: Serious warnings are printed directly to the terminal, which is prioritized down to the next level.2. Print the log to a file.Import logginglogging.basicconfig (File
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.