杂项-Log:NLog
| ylbtech-杂项-Log:NLog |
| 1.返回顶部 |
- 文件
- 文本控制台
- Email
- 数据库
- 网络中的其它计算机(通过TCP或UDP)
- 基于MSMQ的消息队列
- Windows系统日志
- 当前的日期和时间(多种格式)
- 记录等级
- 来源名称
- 输出跟踪消息的方法的堆栈信息
- 环境变量的值
- 异常的详细信息
- 计算机、进程和线程名称
- Trace- 最常见的记录信息,一般用于普通输出
- Debug- 同样是记录信息,不过出现的频率要比Trace少一些,一般用来调试程序
- Info- 信息类型的消息
- Warn- 警告信息,一般用于比较重要的场合
- Error- 错误信息
- Fatal- 致命异常信息。一般来讲,发生致命异常之后程序将无法继续执行。
| 2.返回顶部 |
<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="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 on customizing logging rules and outputs.
-->
<targets>
<default-wrapper xsi:type="AsyncWrapper">
<wrapper-target xsi:type="RetryingWrapper"/>
</default-wrapper>
<!-- add your targets here -->
<target xsi:type="File" name="AllLog" fileName="${basedir}/App_Data/logs/${shortdate}/all.log" layout="${longdate} ${uppercase:${level}} [${threadid}] ${logger} - ${message} ${exception:format=tostring}" />
<target xsi:type="File" name="DebugLog" fileName="${basedir}/App_Data/logs/${shortdate}/debug.log" layout="${longdate} [${threadid}] ${logger} - ${message} ${exception:format=tostring}" />
<target xsi:type="File" name="DelayDebug" fileName="${basedir}/App_Data/logs/${shortdate}/debug.log" layout="${longdate}-${message} ${exception:format=tostring}" />
<target xsi:type="File" name="ErrorLog" fileName="${basedir}/App_Data/logs/${shortdate}/error.log" layout="${longdate} [${threadid}] ${logger} - ${message} ${exception:format=tostring}" />
<target xsi:type="File" name="FatalLog" fileName="${basedir}/App_Data/logs/${shortdate}/fatal.log" layout="${longdate} [${threadid}] ${logger} - ${message} ${exception:format=tostring}" />
<target xsi:type="File" name="InfoLog" fileName="${basedir}/App_Data/logs/${shortdate}/info.log" layout="${longdate} [${threadid}] ${logger} - ${message} ${exception:format=tostring}" />
<target xsi:type="File" name="TraceLog" fileName="${basedir}/App_Data/logs/${shortdate}/trace.log" layout="${longdate} [${threadid}] ${logger} - ${message} ${exception:format=tostring}" />
<target xsi:type="File" name="WarnLog" fileName="${basedir}/App_Data/logs/${shortdate}/warn.log" layout="${longdate} [${threadid}] ${logger} - ${message} ${exception:format=tostring}" /> <target xsi:type="NLogViewer"
name="viewer"
address="udp://127.0.0.1:9999"/>
</targets> <rules>
<!-- add your logging rules here -->
<logger name="*" minlevel="Trace" writeTo="AllLog" />
<logger name="*" level="Debug" writeTo="DelayDebug" />
<logger name="*" level="Error" writeTo="ErrorLog" />
<logger name="*" level="Fatal" writeTo="FatalLog" />
<logger name="*" level="Info" writeTo="InfoLog" />
<logger name="*" level="Trace" writeTo="TraceLog" />
<logger name="*" level="Warn" writeTo="WarnLog" />
<logger name="*"
minlevel="Trace"
writeTo="viewer" />
</rules>
</nlog>
| 3.返回顶部 |
| 4.返回顶部 |
| 5.返回顶部 |
| 6.返回顶部 |
![]() |
作者:ylbtech 出处:http://ylbtech.cnblogs.com/ 本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。 |
杂项-Log:NLog的更多相关文章
- 杂项-Log:log4net
ylbtech-杂项-Log:log4net log4net库是Apache log4j框架在Microsoft .NET平台的实现,是一个帮助程序员将日志信息输出到各种目标(控制台.文件.数据库等) ...
- Net Core 控制台程序使用Nlog 输出到log文件
using CoreImportDataApp.Common; using Microsoft.Extensions.Configuration; using Microsoft.Extensions ...
- NLog配置文件根节点
NLog.config 配置文件信息 <nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi ...
- NLog 传递参数
用NLog记文件日志,一般都用{$basedir}变量,把日志记在运行的目录或者它的子目录下,遇到要写在其他目录的下,看了下Nlog找到用环境变量传参数. .net 里写 Environment.Se ...
- .Netcore之日志组件Log4net、Nlog性能比较
转载请注明出处http://www.cnblogs.com/supernebula/p/7506993.html .Netcore之Log4net.Nlog性能比较 最近在写一个开源.netcore ...
- Net Core平台灵活简单的日志记录框架NLog+SqlServer初体验
Net Core平台灵活简单的日志记录框架NLog+SqlServer初体验 前几天分享的"[Net Core平台灵活简单的日志记录框架NLog+Mysql组合初体验][http://www ...
- Net Core平台灵活简单的日志记录框架NLog+Mysql组合初体验
Net Core平台灵活简单的日志记录框架NLog初体验 前几天分享的"[Net Core集成Exceptionless分布式日志功能以及全局异常过滤][https://www.cnblog ...
- Nlog日志之File
一:简介 NLog是一个简单灵活的.NET日志记录类库.通过使用NLog,我们可以在任何一种.NET语言中输出带有上下文的(contextual information)调试诊断信息,根据喜好配置其表 ...
- NLog日志框架使用探究-1
目录 前言 为什么是NLog? 目的 配置 基本配置 日志等级 输出例子 目标 参数 规则 日志分发 日志收集 结语 参考文档 前言 日志是每个程序的基本模块.本文是为了探究如何通过NLog方便及记录 ...
随机推荐
- 在VS2017环境中编译libxml2库
libxml2库编译 1.下载libxml2,官网是:http://www.xmlsoft.org/downloads.html, 我下载的版本是:libxml2-sources-2.9.7.tar. ...
- [POI2006]SZK-Schools
[POI2006]SZK-Schools luogu #include<bits/stdc++.h> using namespace std; const int N=405,M=1e5+ ...
- Spring声明式事务管理与配置介绍
转至:http://java.9sssd.com/javafw/art/1215 [摘要]本文介绍Spring声明式事务管理与配置,包括Spring声明式事务配置的五种方式.事务的传播属性(Propa ...
- 在数据库中使用数字ID作为主键的表生成主键方法
在数据库开发中,很多时候建一个表的时候会使用一个数字类型来作为主键,使用自增长类型自然会更方便,只是本人从来不喜欢有内容不在自己掌控之中,况且自增长类型在进行数据库复制时会比较麻烦.所以本人一直使用自 ...
- [原创]java WEB学习笔记21:MVC案例完整实践(part 2)---DAO层设计
本博客为原创:综合 尚硅谷(http://www.atguigu.com)的系统教程(深表感谢)和 网络上的现有资源(博客,文档,图书等),资源的出处我会标明 本博客的目的:①总结自己的学习过程,相当 ...
- 【leetnode刷题笔记】Maximum Depth of binary tree
Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along the long ...
- hd acm 1297
问题:n个人排队,要求女生不能单独站,可以全是男生,可以全是女生. 例子:n=7,FFFF,FFMM,FFFM,MFFF,MMFF,MMMM,MFFM(F代表女生,M代表男生). 代码:(来自 蓝飞技 ...
- .net短信接口调用示例(106短信通道)
1. [代码]调用代理示例 using System;using System.Data;using System.Configuration;using System.Collections;usi ...
- HTML5学习记录——3
HTML媒体 1.HTML多媒体 视频格式 .avi 微软开发 .wmv 微软开发 .mpg .mpeg .mov 苹果公司开发 .rm .ram 允许低带宽的视频流 .swf .fl ...
- 分享知识-快乐自己:Nginx概述及如何使用
概述: 什么是 Nginx? Nginx (engine x) 是一款轻量级的 Web 服务器 .反向代理服务器及电子邮件(IMAP/POP3)代理服务器. 什么是反向代理? 反向代理(Reverse ...
