logging-log4net-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Todd <todd_beaul...@yahoo.com>
Subject Re: log4net usage in IIS7.5 ASP.NET MVC (multi assembly) application
Date Wed, 09 May 2012 13:26:19 GMT
Could it be permissions? Remember, when you run locally, you're running under your account.
When you run on a remote server, it's typically configured to run under a service account.
That account needs to have permission to log. Furthermore, if you're using impersonation,
the STARTUP events in global.asax.cs runs under the pool account, but code on the user thread
runs under the impersonated account.
This can be a pain to debug because l4n silently fails under a situation like this and then
disables the appender for the rest of that application's lifetime.

 From: Lenka Rolinek <Lenka.Rolinek@ir.com>
To: log4net-user@logging.apache.org 
Sent: Wednesday, May 9, 2012 8:03 AM
Subject: RE: log4net usage in IIS7.5 ASP.NET MVC (multi assembly) application

I am hoping someone can help… 
We have a multi assembly ASP.NET MVC 3
application that runs on IIS7.5. 
We are using log4net version 1.2.10. 
We call log4net LogManager.GetLogger(“loggerName”).Error(“…”); from all assemblies
of our web application. 
Logging from all assemblies works when we
run our web application on our development systems from MS Studio 2010. 
I.e. the log contains logged information
from all our application assemblies. 
Logging from
assemblies but the main one (the one from which log4net was registered, i.e.
includes global.asax.cs file) does _NOT_ work when we run our web
application installed on IIS7.5. 
I.e. the log
contains logged information from the application assembly only. 
Following is a list of all log4net
‘configuration parts’ in our application: 
1.       Log4net configuration is stored
in a config file dedicated for log4net.   
The content of this file is below. 
<!--To support configuration file change detection. --> 
    <!--To turn the logging off
completely, set threshold to OFF as shown below. --> 
threshold="OFF" --> 
<!--Set root logger level to ERROR or above and its appender to RollingFile. --> 
<!--Note, loggers that are not listed here will use root logger settings. --> 
<!--Logger levels are - 
HH:mm:ss} %5level %logger: %message%newline"/> 
<!--example of exclude filter 
<filter type="log4net.Filter.LoggerMatchFilter"> 
<loggerToMatch value="TextToMatch" /> 
<acceptOnMatch value="false" /> 
2.       We inititialise the logging in
global.asax.cs file using the following API and we are positive the location of
the configuration file is correct. 
      protected void Application_Start() 
            // Configure log4net 
            string webConfigPath = HttpContext.Current.Server.MapPath("~") + @"Web.log4net.config";

log4net.Config.XmlConfigurator.ConfigureAndWatch(new FileInfo(webConfigPath)); 
3.       We also give the web
application pool privileges to create/write log file in the folder that is
meant to contain log files. 
4.       We also enabled getting
HttpContext as suggested on this discussion - http://sgomez.blogspot.com.au/2009/03/log4net-with-wcf-services.html

= AspNetCompatibilityRequirementsMode.Required)] 
= InstanceContextMode.PerCall)] 
   public class DataView 
Is there anything else we must do? 
Is it expected to work with log4net version
Any suggestions? 

This email is intended only for the use of the individual or entity named above and may contain
information that is confidential and/or privileged. If you are not the intended recipient,
you are hereby notified that any dissemination, distribution or copying of this Email is strictly
prohibited. If you have received this Email in error, please notify us immediately by return
email or telephone +61 2 9966 1066 and destroy the original message. Thank You
View raw message