NLog安装:

Install-Package NLog

NLog配置:

<?xml version="1.0" encoding="utf-8" ?>
<configuration> <configSections>
<section name="nlog" type="NLog.Config.ConfigSectionHandler,NLog" />
</configSections> <!--autoReload="true"表示在不重新启动应用程序的情况下,修改配置文件,NLog会自动加载应-->
<!--NLog内部的日志消息写到应用程序目录下的logs文件夹里的internalLog.txt文件中;(-->
<nlog autoReload="true" internalLogLevel="Trace" internalLogFile="logs/internalLog.txt">
<targets>
<!--文件输出(type="File")-->
<target name="FileOutput" type="File" fileName="${basedir}/logs/${shortdate}.log"
layout="${longdate} ${callsite} ${level}:
${message} ${event-context:item=exception} ${stacktrace} ${event-context:item=stacktrace}" />
<!--控制台输出(type="File")-->
<target name="ConsoleOutput" type="Console" layout="${date:format=yyyy-MM-dd HHmmss} ${callsite} ${level} ${message}"></target>
</targets>
<rules>
<!--<logger name="Test" minlevel="Debug" maxlevel="Error" writeTo="FileOutput,ConsoleOutput" />-->
<logger name="*" minlevel="Debug" maxlevel="Error" writeTo="FileOutput,ConsoleOutput" />
</rules>
</nlog> <startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
</configuration>

NLog使用:

 private static readonly Logger Logger = LogManager.GetCurrentClassLogger();//LogManager.GetLogger("Test");
static void Main(string[] args)
{
Logger.Trace("This is Trace");
Logger.Debug("This is Debug");
Logger.Info("This is Info");
Logger.Error("This is Error");
Logger.Fatal("This is Fatal"); Console.ReadLine();
}

最新文章

  1. iOS 之UITextFiled/UITextView小结
  2. Spring的3种切入点PointCut实现
  3. DDNS -VPN设置方法
  4. 用ultraISO 制作一个MSdos启动软盘镜像
  5. [译] 开发者角度,王道之论:Android 与 Windows Phone
  6. 使用resumable.js上传大文件(视频)兵转换flv格式
  7. mmc加工配套问题
  8. form表单target的用法,实现无刷新提交页面
  9. openwrt 包makefile
  10. 关于bool和BOOL的区别
  11. 关于MyEclipse启动报错:Error starting static Resources;下面伴随Failed to start component [StandardServer[8005]]; A child container failed during start.的错误提示解决办法.
  12. 多重影分身——C#中多线程的使用一(基础)
  13. DevExpress ChartControl ViewType.Line
  14. JS获取当前星期几的简易写法
  15. [转][CentOS]修改IP后立即生效
  16. C++/C课程设计(2)工资管理系统功能说明
  17. R vs Python:构建data.frame、读取csv与统计描述
  18. 专题训练之区间DP
  19. 如何从github下载项目的源代码,包含git客户端,直接下载,vs下载
  20. [技巧篇]17.那些年一直再逃避的问题,还债Web阶段!

热门文章

  1. Linux网络协议栈(四)——链路层(1)
  2. context:property-placeholder作用
  3. (转)IE内存泄露,iframe内存泄露造成的原因和解决方案
  4. CCF 201409-1 相邻数对 (水题)
  5. adb: command not found 解決方法(转载)
  6. python 闭包 Closure 函数作为返回值
  7. bzoj 1567: [JSOI2008]Blue Mary的战役地图【二分+hash】
  8. bzoj 2216: [Poi2011]Lightning Conductor【决策单调性dp+分治】
  9. 第一篇(eclipse中的单词)
  10. VirtualBox搭建1主2从虚拟机