Nlog配置实例
彩色Console target
<?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="coloredConsole" xsi:type="ColoredConsole" useDefaultRowHighlightingRules="false" layout="${longdate}|${pad:padding=5:inner=${level:uppercase=true}}|${message}" > <highlight-row condition="level == LogLevel.Debug" foregroundColor="DarkGray" /> <highlight-row condition="level == LogLevel.Info" foregroundColor="Gray" /> <highlight-row condition="level == LogLevel.Warn" foregroundColor="Yellow" /> <highlight-row condition="level == LogLevel.Error" foregroundColor="Red" /> <highlight-row condition="level == LogLevel.Fatal" foregroundColor="Red" backgroundColor="White" /> </target> <target name="infoFile" xsi:type="File" layout="${longdate} ${pad:padding=5:inner=${level:uppercase=true}} ${logger} ${message}" fileName="${basedir}/logs/info.log" keepFileOpen="false" encoding="iso-8859-2" /> <target name="errorFile" xsi:type="File" layout="${longdate} ${pad:padding=5:inner=${level:uppercase=true}} ${logger} ${message}" fileName="${basedir}/logs/error.log" keepFileOpen="false" encoding="iso-8859-2" /> </targets> <rules> <logger name="*" minlevel="Debug" writeTo="coloredConsole" /> <logger name="*" minlevel="Debug" maxlevel="Info" writeTo="infoFile" /> <logger name="*" minlevel="Warn" maxlevel="Fatal" writeTo="errorFile" /> </rules> </nlog>
作者:旭东
出处:http://www.cnblogs.com/HQFZ
关于作者:专注于微软平台项目架构、管理和企业解决方案。现主要从事WinForm、ASP.NET、WPF、WCF、等方面的项目开发、架构、管理。如有问题或建议,请不吝指教!
本文版权归作者,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接。如有问题,可以联系我,非常感谢。
如果您该文觉得不错或者对你有帮助,请点下推荐,让更多的朋友看到,谢谢!