Nlog Log Management tool
--Output log to Folder 1, create a console application by vs.
2, open the Package Manager console. The actions are as follows: Tools, library Package Manager, Package Manager console.
3, in the Package Manager console input command: Install-package Nlog after the installation is successful, the project's reference will automatically add Nlog
Log framework NLog, log framework nlog
Here we will compare it with other products according to the old rules:
Currently, there are two old log frameworks on the. net platform: Log4net and NLog.
We will compare the two frameworks.Log4net
Log4net is a classic log framework that can output logs to the console, files, databases, system events, and emails. It allows
-instance >
It should be noted that the root node is 2.1 configure sub-elements
It must be noted that the first two elements, targets and rules, must be configured. The remaining elements are optional and should be used for more complex configurations. I have never used them again.3. Targets)
The first article has been introduced, should no longer explain, specific output to the detailed configuration of the target, see the document: https://github.com/
NLog output target and type, NLog output target type
Targets: output target node
Target: Configure an output target.
Type output Type:
Console output to the Console
Debugger output to VS Output Window
File output to File
Mail output is sent by Mail
Network output to Network address
Database output to Database
Parameter description:
Layout-Text Content of the log. Default Value:
$ {Longdate} | $ {lev
NLog configuration file root node and nlog configuration file Node
NLog. cnfig configuration file information
> // Declare the variable syntax
Value can be used in Layout expressions, such as Layout
AutoReload Automatic reconfiguration)
Once the program is started, after the NLog. config file is read, it is known th
Encapsulate a NLog + NLog. Mongo-based logging tool LogUtil and nloglogutil
Encapsulate an object based on NLog + NLog. the Mongo Logging Tool class is LogUtil. The code is relatively simple. It mainly integrates the logging target configuration and FileTarget configuration into the class, and uses the cache dependency
configsection mechanism. The configuration file is as follows:
In the second form, the xml configuration file uses
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
If the XML namespace is not specified, the nlog configuration file is case insensitive. If an XML namespace is specified, it is case sensitive. Smart sensing can only work normally when an XML namespace is specified.
Configuration File Element
In the
Author: Jaros aw Kowalski
Dflying Chen: http://dflying.cnblogs.com/
Original article: http://www.nlog-project.org/tutorial.html
This is the second article in The nlog article series. We will use an instance program to demonstrate how to use the nlog book to write logs.
Application Tracking
A long time ago, when no debugger was available and software was mostly based on the console, developers were used
Author: Jaros aw Kowalski
Dflying Chen: http://dflying.cnblogs.com/
Original article: http://www.nlog-project.org/tutorial.html
This is the fourth article in The nlog article series, that is, the last article of the Getting Started tutorial. The following describes how to use nlog to write logs.
Automatic Reconfiguration
The nlog configuration file will be auto
configurations. I have never used them again.3. Targets)
The first article has been introduced, should no longer explain, specific output to the detailed configuration of the target, see the document: https://github.com/nlog/NLog/wiki/Targets4. Routing rules (Rules)
Name-log source/Recorder name (wildcard * is allowed *)
Minlevel-minimum level of the log range matched by this rule
Maxlevel-the highest
Not much nonsense to say directly into the topic.1, in the project to add the application of NlogTwo files will appear after installation2. We open Nlog.config profile settings loggingXML version= "1.0" encoding= "Utf-8"?>Nlogxmlns= "Http://www.nlog-project.org/schemas/NLog.xsd"Xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance"> See Https://github.com/nlog/nlog/wiki/Configuration-file For information o
Applications can not be separated from the log, although the use of VS has a powerful debugging capabilities, the development process is not too complicated to output the log (think of print and echo of the wood), but in some complex process and the application of daily running log is still very useful.ASP. NET core provides a built-in log, but does not understand that it is output to a file, only in the output of VS, who knows how to tell me. (ASP. NET Core Series Catalog ) This
core how to use AH?
You have to create a new ASP. NET core project before you use it. Let's take the net core API for example. As shown in the Net Core API project that the blogger has just created.
What to do after building a project, of course, to add references. You can use NuGet or command to install it at your own whim.Install-Package NLog -Version 4.5.7Install-Package NLog.Web.AspN
configure, both through configuration file and programmatically. This sentence is the most important in the official document. It shows how to apply it to your project. Two methods are provided: configuration files and background programming.
Files-Single file or multiple, with automatic file naming and archival
Event Log-Local or remote
Database-Store your logs in databases supported by. net
Network-Using TCP, UDP, soap, MSMQ protocols
Command-line Console-Including color coding of messa
ASP. NET Core learn the third NLog log, corenlog
The previous article briefly introduced how to use logs. It is only used for learning, not to mention that logs can only be output on the console.
NLog is already a member of the logstore and is easy to use. The environment described in this article is in. net core 2.0, and the current version is only beta.1. installation and configuration 1. Installation
The
"Internalloglevel="Off"internallogfile="C:\temp\nlog-internal.log"> "MyVar"Value="myvalue"/> "Console"Name="Console"layout="[${date:format=yyyy-mm-dd Hh\:mm\:ss}][${level}] ${message} ${exception}"/> "File"Filename="${date:format=yyyy-mm-dd}.txt"Name="logfile"/> "*"Minlevel="Trace"writeto="Console"Final="true">"*"Minlevel="Trace"writeto="logfile">Configuration Information Development:Logger label pair, control output range and levelName property:Speci
Label:Recently studied Nlog this log frame, here to record how to write the log to SQLite. First step: Use NuGet to get nlog and SQLite
The second step: Create a database in SQLite, here I use the SQLite Expert Personal visualization tool
The third step: Configure the target node in the Nlog.config, this in Nlog's official website did not find the corresponding
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.