views:

128

answers:

2

I have a seperate Log4Net.config file. I added

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

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?

+3  A: 

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>
Andy White
it was permission problem. thanks.
Andy , please specify.... what do you mean by "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)." How do i fix it ?
Rodniko
Rodniko - I updated my answer to show how to check these permissions.
Andy White
A: 

user177883, Can you please specify how you solved the permission problem ? i have the same problem,

can someone help me solve this permission problem ? how can i change the appPool permissions?

Rodniko
See my updated answer above... hope that helps
Andy White
it was a permission error. make sure you place it somewhere, you can read write etc.