logging-log4net-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Lenka Rolinek" <Lenka.Roli...@ir.com>
Subject RE: log4net usage in IIS7.5 ASP.NET MVC (multi assembly) application
Date Wed, 09 May 2012 12:03:27 GMT
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.

 

<?xml version="1.0" encoding="utf-8" ?>

<configuration>

 

    <configSections>

        <!-- To support configuration file change detection. -->

        <section name="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>

            <level value="ALL" />

            <appender-ref ref="RollingFile" />

        </root>

        <appender name="RollingFile"
type="log4net.Appender.RollingFileAppender">

            <file value="logFile.txt" />

            <appendToFile value="true" />

            <staticLogFileName value="true" />

            <rollingStyle value="Size" />

            <maximumFileSize value="10MB" />

            <maxSizeRollBackups value="5" />

            <layout type="log4net.Layout.PatternLayout">

                <conversionPattern value="%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