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.
The NLog. Web. AspNetCore-package supports the platforms: For ASP.NET Core 6, .
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.
Does NLog.config have the property "Copy to Output Directory" set as "Copy always"?
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:
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