开发者

log4net configuration problem

开发者 https://www.devze.com 2022-12-30 03:33 出处:网络
I have a seperate Log4Net.config file. I added [assembly: log4net.Config.XmlConfigurator(ConfigFile = \"Log4Net.config\", Watch = true)]

I have a seperate Log4Net.config file. I added

[assembly: log4net.Config.XmlConfigurator(ConfigFile = "Log4Net.config", Watch = true)]
开发者_如何学C

to AssemblyInfo.cs

When I run the application with debug mode, lognet is logging. When i publish the application to IIS, lognet is not logging anything.

I have the followings also :

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

What would be the reason for this?


It could be that the AppPool identity user does not have permissions to write to the log file/directory (assuming you're using a file appender).

Here's how to check the AppPool user account:

  • Start->Run->"compmgmt.msc" (or right-click "My Computer" and select "Manage")
  • Navigate to "Services and Applications"->"Internet Information Service (IIS) Manager"
  • Find your site under "Web Sites" and right click->Properties
  • On the Virtual Directory tab, make a note of the "Application pool" setting
  • Cancel this dialog, and navigate to "Application pools" in the IIS manager
  • Right click the app pool you noted above, select Properties, and select the Identity tab
  • This shows the user account that is running the site.
  • Now, my suggestion is to check the folder permissions where you are trying to write the log, and make sure the app pool user has write access to the folder.

If that's not the problem, I'd recommend turning on the log4net internal debugging:

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

精彩评论

暂无评论...
验证码 换一张
取 消