博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Nlog Layout
阅读量:4519 次
发布时间:2019-06-08

本文共 1032 字,大约阅读时间需要 3 分钟。

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()

转载于:https://www.cnblogs.com/peteryu007/p/4218286.html

你可能感兴趣的文章
构建之法阅读笔记01
查看>>
【旧文章搬运】调试没有符号的驱动时如何断在入口点处
查看>>
1301 邻值查找(set 平衡树 | 链表)
查看>>
ssl1692-魔板【HSAH,bfs】
查看>>
[Ramda] Refactor to Point Free Functions with Ramda using compose and converge
查看>>
[Vue + TS] Create your own Decorators in Vue with TypeScript
查看>>
[Python] isinstance() for checking object type
查看>>
[MODx] Build a CMP (Custom manager page) using MIGX in MODX 2.3 -- 1
查看>>
运行osgdem找不到nvtt.dll,以及不能添加纹理图像的解决方法
查看>>
MySQL数值类型
查看>>
flex布局
查看>>
通过HBase Shell与HBase交互
查看>>
java基础--extension package commons(3)
查看>>
基于Lumisoft.NET组件的POP3邮件接收和删除操作
查看>>
JSON日期时间格式转换
查看>>
《计算机组成结构化方法》读书笔记-1
查看>>
jquery 导航固定的一个实例
查看>>
go语言调用cmd
查看>>
jQuery中.bind() .live() .delegate() .on()区别
查看>>
暑假第五测
查看>>