Monolog follows the PSR3 interface specification and can easily be replaced with other log class libraries that follow the same specification. Monolog has a good extensibility, through the handler, formatter and processor these interfaces, can be a variety of Monolog class library extension and customization.
Basic usage
Monolog can be installed via GitHub or composer, and the following is the latest version to install using composer:
Composer require Monolog/monologWhat if you don't know wha
using the logging module, you first need to get an instance of the logger class called the Logger (logger). Each logger has a name, and the logging module manages these loggers by name, and the two loggers can be identified by a hierarchy of namespaces (each instance have a name, and they is conceptually Arranged in a
This article does not teach you a full understanding of log4net. It just wants to teach you how to use log4net1. Introduce the log4net. dll component.2. Create a configuration fileEither method is in Web. config or app. config.Add the following configuration sectionIn the configuration section above, you can use the copy function.
Add the definition of log4net configuration content, followed by the above content definition in the config file. The following is an example:
If you are too lazy to w
Log4cplus is excellent in many aspects, but it is uncomfortable to use it in some places. I'm not happy with it until I continue to talk about it.I will mention it a little and continue to introduce the knowledge about threads and sockets.### Some improvements ###1. The implementation mechanism of user-defined loglevel is not open enoughIn article 5, I have introduced how to implement custom loglevel. To achieve better results, I even need to change log4cplus.Source code. :(2. The mechanism for
Record logs in a unified mode
Recording logs of various levels is an indispensable function for all applications. There are too many third-party frameworks available for the implementation of log records, such as log4net, nlog, loggr, and serilog, of course, we can also choose the Microsoft native diagnostic framework (the relevant API is defined in the namespace "system. in diagnostics .. Net core provides an independent LOG model so that we can use a unified API to program log records. We can
prepare the basic knowledge
Four components of the logging
Loggers provides interfaces that applications can use directly
Handlers send logs to the appropriate destination
Filters provides a way to filter log information
Formatters specifying the Log display format
See the code below #!/usr/bin/env python#-*-coding:utf-8-*-#pyversion:p ython3.5#owner:fuzjimport Logginglogger = Logging.getlogger ("test.conf") #创建一个
in the Lua script This is a little troublesome. However, I wrapped a luaplushelper. h file, which can easily complete this job. Its implementation is also very simple. You can obtain from the source code how to use pure luaplus to implement the same function. However, there is still a restriction that cannot be solved: Virtual member functions cannot be used. However, considering that we only call the C ++ function in Lua, it is not necessary to import C ++ to Lua perfectly. This restriction
, considering that we only call the C ++ function in Lua, it is not necessary to import C ++ to Lua perfectly. This restriction is completely acceptable.In addition, class member variables cannot be directly accessed in Lua, and can be accessed through class member functions (such as setvalue/getvalue ).
// The following is a simple C ++ class:Class Logger{Public:Void logmember (const char * message){Printf ("in member function: % s \ n", message );}
restriction that cannot be solved: Virtual member functions cannot be used. However, considering that we only call the C ++ function in Lua, it is not necessary to import C ++ to Lua perfectly. This restriction is completely acceptable.
In addition, class member variables cannot be directly accessed in Lua, and can be accessed through class member functions, such as SetValue/GetValue ).
// The following is a simple C ++ class:
Class Logger
{
[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 the downloaded pdf version, should be consistent: https://docs.python.org/2/howto/logging.ht
3. Complete Solution
Sunny developers decided to use the factory method mode to design the logger. Its basic structure is shown in 3:
Figure 3 log recorder Structure
In Figure 3, the logger interface acts as an abstract product. Its sub-classes filelogger and databaselogger act as specific products, the loggerfactory interface acts as an abstract factory, and its sub-classes fileloggerfactory and databasel
introduction logging module is a python built-in standard module, mainly used for output log, you can set the level of output logs, log save path, log files and rollback, etc. It can be said that the logging module consists mainly of 4 parts: *logger Logger , which provides interfaces that application code can use directly NBSP;NBSP; *handler processor , sends log records generated by the
log4jthree main componentsLoggers: A tool for logging logs, which is used to record the log information we want.Appenders (output source): Where the log output can be, console, file, stream location, database, and so on.Layouts (layout mode): The log needs to record which basic information, in what format to record the display of this information.A Logger must have at least one Appender, and a Appender has a Layout.LoggersThe
Logging Module Introduction
Python's logging module provides a common logging system that can be easily used by Third-party modules or applications. This module provides different log levels and can record logs in different ways, such as files, HTTP get/post,smtp,socket, etc., and can even implement specific logging methods for itself.The logging module is the same as the log4j mechanism, but the specific implementation details are different. module provides
The benefits of Log4j 2 will not be discussed with everyone. If you search for 2, it means you have some knowledge about it and want to use it, so you can get started directly here.
1. Download log4j 2 from the official website.To import the jar package, you only need to import the following two jar packages (xx is a messy version ):
Log4j-core-xx.jar
Log4j-api-xx.jar
2. Import to your project:This will not be said.
3. Start Using:
We know that to use log4j to record logs in a class, we only
This article is transferred from Kenby's blog, more comprehensive move, turn to stay for later use.http://kenby.iteye.com/blog/1162698First, starting from a usage scenarioImportLogging#Create a loggerLogger = Logging.getlogger ('MyLogger') Logger.setlevel (logging. DEBUG)#create a handler to write to the log fileFH = logging. Filehandler ('Test.log') Fh.setlevel (logging. DEBUG)#create another handler for output to the consoleCH =logging. Streamhandler () Ch.setlevel (logging. DEBUG)#define the
15th General API15.1 Log 15.1.1 Log API Introduction1, java.util.logging package provides the log function related classes and interfaces, do not need to configure the log components, can be used in the standard Java platform is its advantage. The starting point for using the log is the logger class, and the constructor for the logger class is labeled protected. A class that is not a java.util.logging packa
solve the above problems, you need to understand a few of the more important concepts,Logger,Handler,Formatter,FilterA few important concepts
The Logger recorder exposes an interface that the application code can use directly.
Handler processor that sends (logger-generated) log records to the appropriate destination.
Filter filters provide bette
?
Before you solve the above problems, you need to understand a few of the more important concepts,Logger,Handler,Formatter,Filter3. A few important concepts
The Logger recorder exposes an interface that the application code can use directly.
Handler processor that sends (logger-generated) log records to the appropriate destination.
Fil
Simplifies the glog, only retains the function of writing log files, only to rewrite the Linux version, the win version is not rewritten, you can useLog (INFO) Log_if (info,condition) You can also call the Log Class Logger::getinstance () directly. Error and other ways to write a logCall Initlogging (Argv[0],info, "./log/test") when initializing;The first parameter is the path, the second parameter is the lowest log level, and the third parameter repr
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.