Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Question
Thursday, July 26, 2018 4:12 AM
Hi
I have the Nlog.config but it doesn't work in windows or console app:
<?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" autoReload="true"
throwExceptions="false" internalLogFile="D:\NLogErrors\ErrorLogFile.txt" >
<extensions>
<!-- load NLog.Extended to enable ASP.NET-specific functionality -->
<add assembly="NLog.Extended" />
</extensions>
<!--Define Various Log Targets like files, database or asp.net trace files-->
<targets>
<target name="console" xsi:type="ColoredConsole" layout="${message}" />
<!--Write logs to File where we want to write error logs-->
<target name="file" xsi:type="File" fileName="${basedir}/logs/${shortdate}.WebErrorLogFile.txt"
layout=" ${level}(${longdate})${machinename} ${newline}
${newline}
Exception Type:${exception:format=Type}${newline}
Exception Message:${exception:format=Message}${newline}
Additional Info:${message}${newline}
ProcessId:${processid}${newline}
ProcessName:${processname}${newline}
ProcessAccountName:${windows-identity}${newline}
MachineName:${machinename}${newline}
ThreadId:${threadid}${newline}
Stack Trace:${exception:format=Stack Trace}${newline}
">
</target>
</targets>
<rules>
<logger name="*" minlevel="trace" writeTo="file" />
</rules>
</nlog>
I don't understand the mistake. Does Nlog work only in ASPNET or WCF?
All replies (1)
Friday, August 3, 2018 4:11 AM âś…Answered | 1 vote
Hi
I identified the problem. It was that NLog.config wasn't in the same directory that the exe file.