Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is my NLog configuration not working on my server machine?

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?

like image 437
icube Avatar asked Nov 24 '22 05:11

icube


1 Answers

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.

like image 70
Paulo Correia Avatar answered Dec 06 '22 07:12

Paulo Correia