Nlog Layout
Nlog.config
<targets>
<target type="Console" name="trace" layout="${message}${newline}${onexception:inner=${newline} *****Error***** ${newline} ${exception:format=toString}${exception:format=StackTrace}}"/>
</targets>
主要Layout这段,当不是异常的时候显示Message,异常时候显示异常类型和StackTrace
也可加入${stacktrace},平时也可以显示Stacktrace。
private static void aa()
{
var logger = LogManager.GetCurrentClassLogger(); logger.Info("Hello1");
logger.Info("Hello2");
logger.Info("Hello3");
try{
throw new Exception("Test Exception",new Exception("Inner"));
}
catch(Exception error)
{
logger.InfoException("error1",error); } }
输出
Hello1
Hello2
Hello3
error1
*****Error*****
System.Exception: Test Exception ---> System.Exception: Inner
--- 内部异常堆栈跟踪的结尾 ---
在 testNlog.Program.aa() 在 testNlog.Program.aa()
Nlog Layout的更多相关文章
- [转]NLog Layout Renderers ${}
https://github.com/nlog/NLog/wiki/Layout-Renderers Layout renderers are template macros that are use ...
- [转]Using NLog for ASP.NET Core to write custom information to the database
本文转自:https://github.com/NLog/NLog/issues/1366 In the previous versions of NLog it was easily possibl ...
- 关于NLog的target和Layout
这个没啥好说的,都是用别人的东西,看文档就行了,写的很详细. https://github.com/NLog/NLog/wiki/Configuration-file https://github.c ...
- Nlog配置实例
彩色Console target <?xml version="1.0" encoding="utf-8" ?> <nlog xmlns= ...
- NLog在Asp.Net MVC的实战应用
Asp.Net MVC FilterAttribute特性.读取xml反序列化.NLog实战系列文章 首先新建一个MVC project. 一.NLog的配置. 作者:Jarosław Kowalsk ...
- [转]C# 使用Nlog记录日志到数据库
本文转自:http://www.cnblogs.com/weixing/archive/2013/04/26/3044422.html 摘要]Nlog是一个很不错的.NET日志记录组件,它可以将日志输 ...
- [转]ASP.NET Core 开发-Logging 使用NLog 写日志文件
本文转自:http://www.cnblogs.com/Leo_wl/p/5561812.html ASP.NET Core 开发-Logging 使用NLog 写日志文件. NLog 可以适用于 . ...
- Logging with NLog
相比较log4net, 我更喜欢NLog, 因为NLog 更简单, 而且配置选项也更加的清楚,可能是因为log4net 是从log4j 移植过来的一个原因吧,总感觉有很多的java 成分在. 要使用N ...
- C#开源日志Nlog入门
c#语言使用的日志比较多,比如:Log4.NLog等,今天我就简单随笔记录哈NLog的使用. 1.NLog的安装: 直接在VS编译器中打开程序包管理器,输入Install-Package NLogin ...
随机推荐
- Java 8 VM GC Tunning Guide Charter 5
第5章 Available GC The Java HotSpot VM includes three different types of collectors, each with differe ...
- WPF多语言化的实现
Metro插件系统系列就暂时停一下,这次我们讨论一下WPF的资源本地化实现,主要用到的:CultureInfo,ResourceManger,MarkupExtension,RESX文件,这些都是.N ...
- C# - 设置DLL的属性Embed Interop Type 设为False
错误: Error msg: A reference was created to embedded interop assembly. because of an indirect referenc ...
- JAVA里的String、Timestamp、Date相互转换(转)
转自:http://blog.sina.com.cn/s/blog_6675493d0100lbfl.html Timestamp转化为String: SimpleDateFormat df = ne ...
- Tern Server Timeout
- C++ 面试题整理
我和朋友们面到的c++试题整理 虚表 static const sizeof 可构造不可继承的类 stl Iterator失效 map vector vector的removed_if 优化 ---- ...
- HTTP请求报文与响应报文
http://docs.telerik.com/fiddler/KnowledgeBase/HTTP HTTP请求报文与响应报文 HTTP http://www.w3.org/Protocols/rf ...
- Oracle调优总结(经典实践 重要)
转载:http://langgufu.iteye.com/blog/1974211 Problem Description:1.每个表的结构及主键索引情况2.每个表的count(*)记录是多少3.对于 ...
- 2> How Struts 2 Works
The first thing we should consider is that the workflow of figure 1.4 still obeys the sim- pler MVC ...
- hdu 3972 1 M possible
一般做法: 显然的超内存 #include<stdio.h> #include<algorithm> using namespace std; ],ans[]; int mai ...