很實(shí)用的NLog配置分享
前言
NLog是一個(gè)基于.NET平臺(tái)編寫的類庫(kù),我們可以使用NLog在應(yīng)用程序中添加極為完善的跟蹤調(diào)試代碼。本文主要介紹的是關(guān)于NLog配置的相關(guān)內(nèi)容,下面話不多說了,來一起看看詳細(xì)的介紹吧
NLog配置
新建一個(gè)文件命名為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>
第二種:
<?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"> <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>
總結(jié)
以上就是這篇文章的全部?jī)?nèi)容了,希望本文的內(nèi)容對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,謝謝大家對(duì)腳本之家的支持。
相關(guān)文章
asp.net編程獲取項(xiàng)目根目錄實(shí)現(xiàn)方法集合
這篇文章主要介紹了asp.net編程獲取項(xiàng)目根目錄實(shí)現(xiàn)方法,結(jié)合實(shí)例形式分析總結(jié)了asp.net針對(duì)項(xiàng)目目錄的操作技巧與注意事項(xiàng),需要的朋友可以參考下2015-11-11ASPX向ASCX傳值以及文本創(chuàng)建圖片(附源碼)
把用戶在TextBox輸入的文字創(chuàng)建為一個(gè)圖片,ASCX的ImageButton的ImageUrl重新指向這剛產(chǎn)生的圖片,接下來介紹下ASPX向ASCX傳值,感興趣的朋友可以參考下哈2013-03-03asp.net中SqlCacheDependency緩存技術(shù)概述
這篇文章主要介紹了asp.net中SqlCacheDependency緩存技術(shù)概述,是大型web程序設(shè)計(jì)中常用的技術(shù),本文對(duì)此進(jìn)行了較為詳細(xì)的描述,需要的朋友可以參考下2014-08-08基于Asp.Net MVC4 Bundle捆綁壓縮技術(shù)的介紹
本篇文章,小編將為大家介紹,Asp.Net MVC4 Bundle捆綁壓縮技術(shù),有需要的朋友可以參考一下2013-04-04asp.net Request.ServerVariables[] 讀解
asp.net Request.ServerVariables[] 讀解,學(xué)習(xí).net的朋友可以參考下,方便獲取服務(wù)器的一些信息。2011-08-08.net cs后臺(tái)刷新aspx頁(yè)面的四種方式
這篇文章主要介紹了.net cs后臺(tái)刷新aspx頁(yè)面的四種方式,需要的朋友可以參考下2014-03-03