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
  

 
Hi, 
  
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. 
  
<?xmlversion="1.0"encoding="utf-8"?> 
<configuration> 
  
    <configSections> 
       
<!--To support configuration file change detection. --> 
       
<sectionname="log4net"type="log4net.Config.Log4NetConfigurationSectionHandler,
log4net"/> 
    </configSections> 
  
    <!--To turn the logging off
completely, set threshold to OFF as shown below. --> 
    <!--log4net
threshold="OFF" --> 
    <log4net> 
       
<!--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 - 
       
All  DEBUG  INFO  WARN  ERROR  FATAL  OFF 
        --> 
       
<root> 
           
<levelvalue="ALL"/> 
           
<appender-refref="RollingFile"/> 
       
</root> 
       
<appendername="RollingFile"type="log4net.Appender.RollingFileAppender"> 
           
<filevalue="logFile.txt"/> 
           
<appendToFilevalue="true"/> 
           
<staticLogFileNamevalue="true"/> 
           
<rollingStylevalue="Size"/> 
           
<maximumFileSizevalue="10MB"/> 
           
<maxSizeRollBackupsvalue="5"/> 
           
<layouttype="log4net.Layout.PatternLayout"> 
               
<conversionPatternvalue="%date{yyyy-MM-dd
HH:mm:ss} %5level %logger: %message%newline"/> 
           
</layout> 
                    
<!--example of exclude filter 
           
<filter type="log4net.Filter.LoggerMatchFilter"> 
               
<loggerToMatch value="TextToMatch" /> 
               
<acceptOnMatch value="false" /> 
           
</filter> 
                     --> 
       
</appender> 
    </log4net> 
  
</configuration> 
  
  
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() 
      { 
         try 
         { 
            // 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

   [AspNetCompatibilityRequirements(RequirementsMode
= AspNetCompatibilityRequirementsMode.Required)] 
   [ServiceBehavior(InstanceContextMode
= InstanceContextMode.PerCall)] 
   public class DataView 
   { 
   … 
   } 
  
  
Is there anything else we must do? 
Is it expected to work with log4net version
1.2.10? 
Any suggestions? 
  
  
Regards, 
Lenka 
   
_____________________________________________________________________ 

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
_______________________________________________________________________
Mime
View raw message