Log4net configuration issue

I have a separate Log4Net.config file. I added

[assembly: log4net.Config.XmlConfigurator(ConfigFile = "Log4Net.config", Watch = true)]

in AssemblyInfo.cs

When I launch the application in debug mode, lognet is logged. When I publish an application in IIS, lognet writes nothing.

I also have the following items:

BasicConfigurator.Configure(); // in a method
private static readonly ILog _logger = LogManager.GetLogger(typeof(_Default)); // for the instance

What is the reason for this?

+3
source share
1 answer

Maybe the AppPool authentication user does not have write permissions to the log file / directory (provided that you are using the application file).

Here's how to check your AppPool user account:

  • - > → "compmgmt.msc" ( " " "" )
  • " " → " IIS"
  • "-" - >
  • " " " "
  • " " IIS.
  • , "" ""
  • , .
  • - , , , .

, log4net:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <appSettings>
        <add key="log4net.Internal.Debug" value="true"/>
    </appSettings>
</configuration>
+6

Source: https://habr.com/ru/post/1744645/


All Articles