@ Zheng summary creation date: 2012/10
# Consciousness
ASAP (As Soon As Possible) PrincipleWhen there is a strange problem online and you realize that the problem cannot be located by the existing logs, when the problem is difficult to reproduce in your development environment, please do not stick to the Code, because: 1) not necessarily because of your code logic, dirty data, old business data, distributed environment, or other subsystems. 2) online businesses are in unstable conditions and can
Python outputs log logging to the console and files at the same time,
This example describes how to export logs to the console and files simultaneously by using Python. Share it with you for your reference. The details are as follows:
Python provides a very convenient Log Module for outputting logs to the console and files at the same time.
#-*-Coding: UTF-8-*-import logging # configure log information
First, StreamhandlerStream handler--is included in one of the three handler in the logging module.The ability to output log information to Sys.stdout, Sys.stderr, or class file objects (more specifically, objects that can support the write () and Flush () methods).There is only one parameter:class logging.StreamHandler(stream=None)The log information is output to the specified stream and, if the stream is empty, is output to Sys.stderr by default.Seco
Tags: style blog class code java cFirst, PDB useThe PDB is a Python-brought package that provides an interactive source code debugging feature for Python programs, including setting breakpoints, stepping through debugging, entering function debugging, viewing current code, viewing stack fragments, dynamically changing the values of variables, and more.Insert a program in the middle of the program (import PDB Pdb.set_trace ()), relative to the general IDE inside the breakpoint and then start Debu
first, Basic UsageOnly the basic configuration is required and can be used.import loggingdef fun2 (): logging.basicconfig (filename="fun2.log", format ="% (asctime) s% (message) s", level=logging. DEBUG) logging.debug ("This isfun2 log")second, the detailed configurationFirst add a Filehandler to configure the record of the file, formatter to set the format of the record and time format, GetLogger is to get a specified name logger, and then add
The Logging Application Block in Enterprise Library 2.0 is Logging and Instrumentation Application Block in version 1.0 because it focuses on logging and Renamed as Logging Application Block. Logging Application Block provides a unified
This method is applicable to Win2000 systems. If you use the dial-up function provided by WINXP, it seems that you do not need to log on to the server. You only need to enable the dial-up request to enable automatic dial-up without logging in. Of course, if not, you can also use the following method.
This method is applicable to Win2000 systems.
If you use the dial-up function provided by WINXP, it seems that you do not need to log on to the serve
ObjectiveThere are a number of ways to implement logging in Java,1. The simplest way to do this is system.print.out, err to print the message directly on the console.2. java.util.logging; After the JDK version 1.4, a log API was provided to write logs to the file.3. log4j, the most powerful way to log logs. You can configure the destination, format, and so on for the log by configuring the. Properties or. xml files.4. Commons-
']['Compression'])#YesPrint(config['topsecret.server.com']['ForwardX11'])#NoPrint(config['bitbucket.org'])# forKeyinchconfig['bitbucket.org']:#Note that a key with default defaults will Print(Key)Print(Config.options ('bitbucket.org'))#same for loop, find all keys under ' bitbucket.org 'Print(Config.items ('bitbucket.org'))#Find all key-value pairs under ' bitbucket.org 'Print(Config.get ('bitbucket.org','Compression'))#Yes Get method section key corresponding to valueAdding and removing chan
Module-level functions
Logging.getlogger ([name]): Returns a Logger object that returns root if no name is specified loggerLogging.debug (), Logging.info (), logging.warning (), Logging.error (), logging.critical (): Setting the log level of root loggerLogging.basicconfig (): Create a Streamhandler for the log system with the default formatter, set the base configuration and add it to root logger
Example: logging_level_example.py
Copy Code code as follows:
Import
With the expansion of the network scale, a variety of servers, switches, routers, firewalls and other devices are more and more, the daily management of failures often need to log on to these devices to view the log, but because of a large number of devices, when the fault involves multiple devices, operation is very cumbersome; Some of the equipment on the log on the way to store, some months there is no, very inconvenient for future use. So after a comprehensive comparison of some
syslog-customized service names that the software can use to record the information they generate by invoking the service names described above. such as: SendMail and Postfix and dovecot are mail-related software, these software in the design of the log is the active invocation of the mail service name in SYSLOGD (Log_mail), So the information generated by the a
First, define how the log is printedIf we run our own programs, we sometimes need to log the problems or information that occur during the program's operation. Log module logging can be used to record, the module log format can be based on user needs to define their own.The common form of print log information is as follows:Import Logginglogging.debug ("======== defines what to print ====debug①===========") logging.info ("========= defines what to pri
Django uses the Python buildin logging module.The Python logging consists of four parts:
Loggers-Loggers
Handles-processor
Filters-Filter
Formatters-Format Device
LoggersLogger, Recorder. A logger is a log system entity, each logger is a well-named information "Bucket", in the process of program execution, you can write information inside.The log level is set for each logger, which
Logging Module As the name implies, for the program log output, you can set the log level, format, output mode, etc., the basic use method is as follows:1, Logging.basicconfig Way simple configuration, can only choose to output to the screen alone or output to a file, cannot be output at the same time. For example: #-*-coding:utf-8-*-#只能选择输出到屏幕或文件import logginglogging.basicconfig (level=logging. debug, fo
The Python standard log module uses Handler control log messages to write to different destinations, such as files, streams, messages, sockets, and so on. In addition to the Streamhandler, Filehandler, and Nullhandler definitions in the logging module, the other Handler are defined in the Logging.hangdlers module. These Handler are: Watchedfilehandler, Rotatingfilehandler, Timedrotatingfilehandler, Sockethandler, Datagramhandler, Sysloghandler, Nteven
Python's logging module one, simple to print the log to the screenImport LoggingLogging.debug (' This is debug message ')Logging.info (' This is Info message ')Logging.warning (' This is warning message ')The output is WARNING:root:This is warning message.By default, logging prints the log to the screen with a log level of WARNING and a log-level size relationship: CRITICAL > ERROR > WARNING > INFO > DEBUG
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.