首页| 新闻| 科技| 人物| 科学| 话题| 运营| 设计| 开发| 服务器| 学院| 产品| 网文| 娱乐| 游戏| 图片
前言
NLog是一个基于.NET平台编写的类库,我们可以使用NLog在应用程序中添加极为完善的跟踪调试代码。本文主要介绍的是关于NLog配置的相关内容,下面话不多说了,来一起看看详细的介绍吧
NLog配置
新建一个文件命名为NLog.Config,然后添加如下代码
<?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">
<targets> <target name="asyncFile" xsi:type="AsyncWrapper"> <target name="log_file" xsi:type="File" fileName="${basedir}/Logs/${shortdate}/${shortdate}.txt" layout="${longdate} | ${message} ${onexception:${exception:format=message} ${newline} ${stacktrace} ${newline}" archiveFileName="${basedir}/archives/${shortdate}-{#####}.txt" archiveAboveSize="102400" archiveNumbering="Sequence" concurrentWrites="true" keepFileOpen="false" /> </target> <target name="console" xsi:type="ColoredConsole" layout="[${date:format=HH/:mm/:ss}]:${message} ${exception:format=message}" /> </targets>
<rules> <logger name="*" minlevel="Error" writeTo="asyncFile" /> <logger name="*" minlevel="Debug" writeTo="console" /> </rules> </nlog>
第二种:
<variable name="logLayout" value="Logger:${logger}${newline}Date:${longdate} Level:${uppercase:${level}}${newline}Message:${message} ${newline}${onexception:Exception:${exception:format=toString}${newline}}" />
<targets> <target name="asyncFile" xsi:type="AsyncWrapper"> <target name="log_file" xsi:type="File" fileName="${basedir}/Logs/${shortdate}/${shortdate}.txt" layout="${logLayout}" archiveFileName="${basedir}/archives/${shortdate}-{#####}.txt" archiveAboveSize="102400" archiveNumbering="Sequence" concurrentWrites="false" keepFileOpen="true" encoding="utf-8" openFileCacheTimeout="30"/> </target> </targets>
<rules> <logger name="*" minlevel="Info" writeTo="asyncFile" /> </rules> </nlog>
总结
以上就是这篇文章的全部内容了,希望本文的内容对大家的学习或者工作具有一定的参考学习价值,谢谢大家对CuoXin错新网的支持。
phpwind9.0系统的视觉进化论(
phpwind 的编码错误导致cookie
phpwind的rewrite重写原理
南国有佳人,容华若桃李
怀念青春,憧憬着自己的美好未来
中国旅游景点集锦 美丽的风景
名胜古迹风景 最美的景色
路边摊小吃 酒香不怕巷子深
特色路边摊小吃 下班路上的一道美食
爷爷都是从孙子走过来的
我太帅了,睡不着咋整啊
新闻热点
疑难解答
图片精选
ASP.NET中Multi-ListBox控件编程详
ASP.NET AJAX:UpdatePanel控件
你必须知道的.NET之接口和抽象类
ASP.NET入门数据篇
网友关注