The example mainly solves the problem of changing the log storage location by passing in the log file parameters. If you need it, you can refer to the simple version of logging. config, which supports general configuration through the config file.
Another better way is to use the logging. config. fileConfig (log_config_file) method to read in and modify the handler method.
The Code is as follows:
"""Proje
Basic information for Python's Logging module logging:L By default Python's logging module prints to the console, showing only logs greater than or equal to warning levelL Log level: critical > Error > Warning > Info > Debug > NotSetBasic components of logging: 1. LoggerL logger is a tree-like hierarchy, and the output information is preceded by a loggerL logger
1. Simply print the log to the screen
importlogginglogging.debug(‘This is debug message‘)logging.info(‘This is info message‘)logging.warning(‘This is warning message‘)屏幕上打印:WARNING:root:This is warning message
By default, logging prints the log to the screen with a log level of warning;Log level size relationships are: CRITICAL > ERROR > WARNING > INFO > DEBUG > NOTSET, and of course you can define the log level yourself.2.
In some cases, you can use the logging mode for the table and index segments, or the mode that does not log logs. If you are using a data pump to import a table segment or index segment, you can
Use the nologging mode, and use the data guard or a scenario that is high in availability to record the log, or even use the force log. This article describes how the index segment in the table segment is used
The redo size of the
Objective
It is believed that every programmer should know that when using Python to write background tasks, it is often necessary to use an output log to record the state of the program running, and to save the details of the error in case of an error to debug and analyze. The Python logging module is a good helper in this case.
The logging module can specify the level of
Recently modified the logging related functions in the project and used the logging module in the Python standard library to make some records here. Mainly from official documents and StackOverflow to find some of the content.
Official documents
Technical Blog
Basic usageThe following code shows the most basic usage of logging.#-*-Coding:utf-8-*
Logging module:The logging module in the standard library, which was used to solve the problem of print interruption when learning thread safety earlier, describes the function of the logging module.logging modules are thread-safe and do not require any special work from customers.It achieves this by using thread locks; There is a lock to serialize the access to
1. Simply print the log to the screenImport logginglogging.debug ('This isdebug message') logging.info ( 'this wasinfo message') logging.warning ('This iswarning message ' is warning messageBy default, logging prints the log to the screen with a log level of warning;Log level size relationships are: CRITICAL > ERROR > WARNING > INFO > DEBUG > NOTSET, and of course you can define the log level yourself.2. Configure the output format and mode of the
1. Logging module Log levelA simple example of using the logging module:>>>import logging>>>logging.debug ("This ' s a Test Logging") >>>loggin.info ("Still a test Logging ") # The above two lines do not have output by default, you need to specify the log level to line >>>lo
[Blog recommendation] logging module of python Howto (1)
This blog post is from Bkjia. If you have any questions, go to the blog page for an interactive discussion!Blog: http://xdzw608.blog.51cto.com/4812210/1608718
This article comes from the understanding of the source code added to the howto-logging section in py2.7.9 docs. The official documentation link is as follows, I am using th
that a message needs to be processed, it's passed to a Handler.(Source: https://docs.djangoproject.com/en/1.4/topics/logging/)A simple example#--Coding:utf-8--Import loggingSimple use example of "" "Logging"""if __name__ == ‘__main__‘:# 最简单的用法,不推荐直接用logging模块logging.debug(u‘这个不会被打印出来‘)logging.info(u‘这个也不会被打印出来‘)logging.warning(u‘这个就会了,因为
As I posted before, logging is an important debugging means. In order to be truly useful and convenient, the logging module shoshould at lease have two traits:
Can be turned on and off globally
Supports the concept of logging level
Osip also comes with a mature logging system. besides the traits I just m
debugging (Debugging) and logging (logging) are very important when you are developing a program, but there are too many logging APIs available now because they're all good and it's hard to make a choice. The Foreign Java Forum also has some discussion about these logging ways.
And common
Logging, so the name wanton is the log, I 艹, this cultural heritage!Logging is a python built-in log module that facilitates log writing and output for everyday applicationsThe logging is divided into 5 log levels, namely:Debug, info, warning, error, critical (ranked by order)where info is the log level that is often applied in the future, for
ObjectiveWhen the script runs, sometimes do not know the implementation of use cases, this time can join the log, so that the problem is easy to review, it is easy to check which use cases executed, which did not execute.First, package logging module1. About Logging Log introduction, I do not explain in detail here, there are two major functions, one is the output of the console, one is saved to a local fil
For Python, there have been two problems that have plagued me these days:There is no way to get the current line number and function name directly in 1.python. This is a question raised in the Forum, a group of people are just guessing why Python does not provide __line__ and __func__ like __file__, but ultimately did not find a solution.2. If a function does not know its own name, how can you recursively call yourself. This is one of my colleagues asked me, but also to get the function name, bu
running the command, a webpage page is generated, showing various printed information, all data is displayed in the format and size of the document, including the document printed by the user and the printer. At the same time, it can export the report to CSV format, so that you can summarize and organize it in Excel.
With this data, we can audit printed content well.
However, pay attention to the following during deployment:
1. If the user knows that the printed log exists, the file name can
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.