杂项-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方便及记录 ...
随机推荐
- StackOverflow&&Quora&&More 翻译系列——目录
启动了一个翻译系列,主要收录个人在伯乐在线上翻译的文章,或者在 StackOverflow.Quora 及其他资讯站上发现的好文,选文比较偏个人喜好.希望能够学习.理解文章的同时提高英语水平,并共享知 ...
- threading.local的作用?
threading.local()这个方法的特点用来保存一个全局变量,但是这个全局变量只有在当前线程才能访问,如果你在开发多线程应用的时候 需要每个线程保存一个单独的数据供当前线程操作,可以考虑使用 ...
- Power Designer体验之旅
版权声明:本文为博主原创文章.未经博主允许不得转载. https://blog.csdn.net/wang13667539325/article/details/36025245 从某种程度上说.不论 ...
- mysql用户和权限管理(Linux系统下)
在mysql自带的库中有一个mysql,这个库包含了太多的东西,其中有一张表user,这张表存储了所有的用户信息. mysql> select user,host,password from u ...
- BestCoder Round #4 之 Miaomiao's Geometry(2014/8/10)
最后收到邮件说注意小数的问题!此代码并没有过所有数据,请读者参考算法, 自己再去修改一下吧!注意小数问题! Miaomiao's Geometry Time Limit: 2000/1000 MS ( ...
- Spring Cloud之统一fallback接口
每个方法都配备一个fallback方法 不利于开发的 用类的方式 并且整个方法都是在同一个线程池里面的 主要对于client的修改: pom: <project xmlns="http ...
- 7zip压缩程序的使用
1.压缩: zip格式: 7zip.exe a -tzip C:\压缩解压测试\TEST.zip C:\压缩解压测试\TEST\* 7z格式: 7zip.exe a -t7z C:\压缩解压测试\TE ...
- LINQ 学习路程 -- 查询操作 Conversion Operators
Method Description AsEnumerable Returns the input sequence as IEnumerable<t> AsQueryable Conve ...
- JSP&EL 内置对象
JSP&EL 内置对象 转载▼ 具体的JSP和El中的内置对象见下表,由于我写在了excel中,也不知道怎么把excel发出来,就截了图. 相关问题: Q1: JSP:EL中 pageCo ...
- asp.net中异步调用WebService(异步页)[转]
由于asp2.0提供了异步页的支持使异步调用WebService的性能有了真正的提升.使用异步页,首先要设置Async="true",异步页是在Prerender和Prerende ...
