I am using ServiceStack framework and NLog to do my logging. I can do logging on my local machine just fine. However on the server, it doesn't. I have checked that the Nlog.config
is in the bin
directory and the whole directory, including the directory above the bin
directory has write access.
Below is a snippet of the config file:
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<targets async="true">
<target xsi:type="File" name="file" fileName="${basedir}\logs\${shortdate}.log" layout="${longdate} ${uppercase:${level}} ${message}" />
<target xsi:type="Debugger" name="debug"
header="===== ${date:format=ddd, dd MMM yyyy} ${time} ====="
layout="${level} | ${logger} | ${message} | ${onexception:${exception:format=tostring} | ${stacktrace}}"
footer="===== end of session ===== ${newline}"
/>
</targets>
<rules>
<logger name="*" minlevel="Trace" writeTo="file,debug" />
</rules>
</nlog>
What might be the problem?
Have you tried to change the path to something you know?
Instead of fileName="${basedir}\logs\${shortdate}.log"
to something like fileName="c:\logs\${shortdate}.log"
?
The basedir
variable of NLog in web applications don't run inside the bin folder. I think you will find the log files inside
%SystemRoot%\Microsoft.NET\Framework\versionNumber\Temporary ASP.NET Files
If it's a ASP.NET app.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With