标签:
<?xml version="1.0" ?> <nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <targets async="true"> <target name="csv" xsi:type="File" fileName="${basedir}/logs/${windows-identity:domain=false}_${shortdate}.csv"> <layout xsi:type="CSVLayout"> <column name="time" layout="${longdate}" /> <column name="level" layout="${level}"/> <column name="logger" layout="${logger}"/> <column name="message" layout="${message}" /> </layout> </target> <!-- write logs to file --> <target name="file" xsi:type="File" fileName="${basedir}/logs/${windows-identity:domain=false}.txt" layout="${longdate} ${logger} ${message}" /> <!-- send mail through GMail server --> <target xsi:type="Mail" name="mail" smtpServer="smtp.163.com" smtpPort="25" enableSsl="false" smtpAuthentication="Basic" smtpUserName="" smtpPassword="111111" from="@163.com" to="qq.com" subject="NLogDemo Test" addNewLines="true" body="${longdate}" /> <!-- send mail asynchronously, so that it does not block the calling thread --> <wrapper-target xsi:type="AsyncWrapper" name="asyncMail"> <target-ref name="mail"/> </wrapper-target> </targets> <rules> <!-- Trace|Debug|Info|Warn|Error|Fatal --> <logger name="*" minlevel="Info" writeTo="mail" /> <logger name="*" minlevel="Warn" writeTo="csv" /> <logger name="*" minlevel="Error" writeTo="mail" /> </rules> </nlog>
发送邮件级别需要调整,目前测试 SSL 发不出邮件,可能 NLog 自身原因
标签:
原文地址:http://www.cnblogs.com/z5337/p/5369004.html