Add below in Webconfig
<configuration>
<configSections>
<section name="nlog" type="NLog.Config.ConfigSectionHandler,
NLog"/>
<configSections>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<variable name="logDirectory" value="D:\LogFiles" />
<targets>
<target name="LogFile" xsi:type="AsyncWrapper">
<target xsi:type="File" fileName="${var:logDirectory}\DirectMessageSender.txt" layout="${longdate}|${level:uppercase=true}|${logger}|${message}${onexception:|${exception:format=toString}}" archiveEvery="Hour" archiveFileName="${var:logDirectory}\DirectMessageSender.{#}.txt" archiveNumbering="Date" archiveDateFormat="yyyy-MM-dd-HH" />
</target>
</targets>
<rules>
<logger name="*" minLevel="DEBUG" appendTo="LogFile" />
</rules>
</nlog>
<configuration>
using NLog;
private Logger
logger = LogManager.GetCurrentClassLogger();
logger.Error(ex);
No comments:
Post a Comment