Nlog and nlog Configuration
Use Case:
Configuration file:
1 <?xml version="1.0" encoding="utf-8" ?> 2 <configuration> 3 <configSections> 4 <section name="nlog" type="NLog.Config.ConfigSectionHandler, NLog"/> 5 </configSections> 6 <nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 7 <targets> 8 <target name="file" xsi:type="File" fileName="${shortdate}.txt" 9 layout="${date:format=HH\:mm\:ss}-${stacktrace}-${message}"/>10 </targets>11 <rules>12 <logger name="*" minlevel="Error" writeTo="file"/>13 </rules>14 </nlog>15 </configuration>
Call:
1 string message = "this is an exception message"; 2 NLog. Logger logger = NLog. LogManager. GetCurrentClassLogger (); 3 logger. Error (message );
Link:
Http://nlog-project.org/
Https://github.com/nlog/nlog/wiki/Configuration-file
Http://www.cnblogs.com/dflying/archive/2006/12/06/584426.html)