杂项-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方便及记录 ...
随机推荐
- 在Nginx/Openresty中启用http2支持
转自个人博客 chinazt.cc 以下摘自http2的介绍: HTTP/2 源自 SPDY/2 SPDY 系列协议由谷歌开发,于 2009 年公开.它的设计目标是降低 50% 的页面加载时间.当下很 ...
- shell if判断-n
test测试命令 test命令用于检查某个条件是否成立,它可以进行数值.字符串和文件三个方面的测试,其测试符和相应的功能分别如下: (1)数值测试: -eq:等于则为真 -ne:不等于则 ...
- Python OOP(3) staticmethod和classmethod统计实例
staticmethod 统计实例 #!python2 #-*- coding:utf-8 -*- class c1: amount_instance=0 def __init__(self): c1 ...
- 期刊搜索问题——SCI、EI、IEEE和中文期刊
1.SCI.EI收录是什么意思? SCI和EI都是收录,并不是实体的期刊出版社,相当于具有高品质期刊出版社的合体(或统充),隔一段时间(几年或者几个月)SCI会进行评估,哪些出版社不具有被SCI收录的 ...
- 【leetcode刷题笔记】Implement strStr()
Implement strStr(). Returns a pointer to the first occurrence of needle in haystack, or null if need ...
- P4022 [CTSC2012]熟悉的文章
题目 P4022 [CTSC2012]熟悉的文章 题目大意:多个文本串,多个匹配串,我们求\(L\),\(L\)指(匹配串中\(≥L\)长度的子串出现在文本串才为"熟悉",使得匹配 ...
- 第三篇 css属性
一.颜色属性 颜色属性有下面四种方式 <div style="color:blueviolet">ppppp</div> <div style=&qu ...
- Idea中配置Tomcat7的JNDI
1.进入目录 D:\apache-tomcat-7.0.73\conf\Catalina\localhost 添加hello.xml ,内容为: <Context path="/hel ...
- jsp的9个内置对象
Jsp提供了request.response.session.application.out.page.config.exception.pageContext9个内置对象. 1. Request R ...
- Windows默认字符集_查询
https://zhidao.baidu.com/question/32462047.html Windows95. XP……7操作系统自带的都是GBK字符集(含2万余汉字),是完全兼容GB2312( ...
