Python logger module and pythonlogger Module1 Introduction to the logging Module
The logging module is a standard module built in Python. It is mainly used to output running logs. It can be used to set the log output level, log storage path, and log file rollback. Compared with print, it has the following advantages:Logger is never directly instantiated and often
, if the parent logger level is not set, continue to find the parent's parent, finally found root, if the root set to use it, if root is not set, the default value of root is warning3. Generate some level of information on a logger, first and logger levels, if the message level is lower than Logger's EFFECTIVELEVL, the message is discarded and the message is no l
For details about how to implement the Logger printing function in Python, pythonlogger
Preface
It is well known that there is a logging kit specifically used for logger printing in Python, but the logger of this kit only receives the printing information of a string type
Python's logging module provides a common logging system, and skilled use of the logging module makes it easy for developers to develop third-party modules or their own Python applications.Python uses the logging module to log logs involving four main classes:Logger: Provides an interface that the application can use directly;Handler: Sends (logger created) log records to the appropriate destination.Filter:
Links:Http://www.cnblogs.com/anpengapple/p/5048123.htmlJsonImport JSONThe list of objects that are serialized.JSON, though it looks like a dictionary, is a string.The quotation marks in the JSON standard format are double quotes.This process is serialized and written to the file.Deserialization:Serialization stringAnother way to apply dumpWrite the content and, F is equivalent to adding a write operationAnother way to apply loadEquivalent to read and loadsPickleThe Pickle module has the advanta
the Logging.handlers class is used to obtain a handler. The approximate wording is:1 logger = Logging.getlogger ()#Get Logger2 handler = Logging.handlers.TimedRotatingFileHandler (logfile, "s", 1, 0) # cut log 3 handler.suffix = ' %y%m%d" post-cut log settings suffix 4 Logger.addhandler (handler) # add logger on Handler5 logger.fatal ( Datetime.datetime.now (). Strftime ( ' %y-%m-%d# is written in the
) s ', datefmt= '%y/%m/%d%h:%m:%s ') ch.setformatter (Ch_formatter) fh.setformatter (fh_formatter) logger.addhandler (CH) logger.addhandler (FH) # Here you need to return the logger to returnlogger ' ' is an additional assignment statement, and calling the log module simplyTo invoke the following 1 or more variables is OK no need to call the above function, each required log name first defines the good one variable in addition, the following defini
Usage of the Log moduleJSON sectionFirst Test code: note STR can directly handle the dictionary eval can directly convert the string into a dictionary formdic={' Key1 ':' Value1 ',' Key2 ':' Value2 '}Data=StrDiC#字典直接转成字符串Printtype (data), data) # # with open (' Db.txt ', ' W ', encoding= ' utf-8 ') As f: # f.write (str (DIC)) # with open ( Db.txt ', Enco
Recently just done a project about Socket TCP communication.The demand side provides an ARM machine, and a data logger, which requires me to do a service-side interaction with the data collector.Objective:Data logger: Periodically sends the readings to the server.Server: The data
#!/user/bin/python#-*-coding:utf-8-*-" "subprocess: Need to test shelllogging on Linux platform" "ImportLogging#output The log in a file#logging.basicconfig (filename= "App.log", level=logging. DEBUG)Logging.basicconfig (filename="App.log", level=logging. WARNING, Format='% (asctime) s% (levelname) s% (filename) s:% (lineno) d-% (message) s', Datefmt='%m/%d/%y%i:%m:%s%p')#add time to the log.%p represents PM. TODO Why not hit the number of trips?Loggi
I didn't have a rest during the Spring Festival. I 've been fighting for it. For my second masterpiece, DVD-Logger, a small program used to record the disc data, I hope it will bring you convenience.
With the popularity of recorders, you will learn more or less some CDs to save less frequently-used data. However, finding these
Atitit. Data Logger dataspider/atiplat_cms/src/com/attilax/webinfox.java @dephttp://cl.cmcher.com/thread0806.php?fid=16search=page=2/atiplat_cms/src/com/attilax/dataspider/tsaolyonetdataspider.javaCrawler Considerationssetting useragent as FFNote for https: mainly because of Java their httpurlconnection to SSL support is not good, and control is not convenient, and httpclient also support to crawl non-trus
Bank Chip card Data Collector "Consulting: 147xx5861xx5123" micro. The letter has opened the webpage can't open please contact directly, we have entity, when you enter the Xianghe County People's court, feel the rich cultural atmosphere of party building: corridor, court, Litigation Service center, Everywhere pictures, slogans, etc. Always remind each judge to remember the purpose of the party, practical practice of justice for the people's purpose, a
#!/user/bin/python#-*-coding:utf-8-*-" "subprocess: Need to test shelllogging on Linux platform" "ImportLogging#output The log in a file#logging.basicconfig (filename= "App.log", level=logging. DEBUG)Logging.basicconfig (filename="App.log", level=logging. WARNING, Format='% (asctime) s% (levelname) s% (filename) s:% (lineno) d-% (message) s', Datefmt='%m/%d/%y%i:%m:%s%p')#add time to the log.%p represents PM. TODO Why not hit the number of trips?
Python learning-Basic Python data types (1), python learning Data Types
Python3 Basic Data Type Variables in Python3 do not need to be declared. Each variable must be assigned a value before it can be used.Python3 has six standa
Course Description:Python Data analysis Basics and Practices Python data analysis Practice Course Python Video tutorial----------------------Course Catalogue------------------------------├├├├├├├├; Baidu Network DiskPython Data analysis Basics and Practices
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.