Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NLog doen't work on IIS

I added NLog to my project. Following the instructions I created NLog.config.

<?xml version="1.0" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

    <targets>
        <target name="file" xsi:type="File"
            layout="${longdate} ${logger} ${message}" 
            fileName="${basedir}/${shortdate}.log" />
    </targets>

    <rules>
        <logger name="*" minlevel="Debug" writeTo="file" />
    </rules>
</nlog>

and then just log something.

var logger = LogManager.GetCurrentClassLogger();
logger.Info("xxxx");

With the developer web server it work fine, but when I publish the app to IIS, no logs are created.

like image 595
user49126 Avatar asked Jan 13 '12 11:01

user49126


People also ask

Does NLog support .NET 6?

The NLog. Web. AspNetCore-package supports the platforms: For ASP.NET Core 6, .

What is NLog in .NET core?

NLog is a flexible and free logging platform for various . NET platforms, including . NET standard. NLog makes it easy to write to several targets. (database, file, console) and change the logging configuration on-the-fly.


2 Answers

Does NLog.config have the property "Copy to Output Directory" set as "Copy always"?

like image 174
kolbasov Avatar answered Sep 28 '22 01:09

kolbasov


Edit website permissions in IIS and under security tab give IIS_IUSRS group full privileges.

In Application, Pools find the pool your application is using and set some specific user.

The image below describes the procedure step by step:

Steps using IIS Images to assign a user.

like image 31
Asad Naeem Avatar answered Sep 28 '22 03:09

Asad Naeem