views:

152

answers:

1

Hi All,

I have an iis server on a windows 2003 production machine that will not log using log4net in the .net3.5 web application. Log4net works fine in the 1.1 apps using log4net version 1.2.9.0 and but not the 3.5 web app. The logging works fine in a development and staging environment but not in production. It does not error and I receive no events logged in the event viewer and don't know where to look next. I have tried both versions of log4net (1.2.9.0 and 1.2.10.0) and both work in development and staging but not in production.

For testing purposes I have created just a single page application that just echos back the time when the page is hit and also is supposed to log to my logfile using log4net.

Here is my web.config file:

    <configSections>
    <!-- LOG4NET Configuration -->
    <section name="log4net"  type="log4net.Config.Log4NetConfigurationSectionHandler,log4net" requirePermission="false" />
</configSections>

<log4net debug="true">
    <appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender">
        <param name="File" value="D:\DIF\Logs\TestApp\TestApp_"/>
        <param name="AppendToFile" value="true"/>
        <param name="RollingStyle" value="Date"/>
        <param name="DatePattern" value="yyyyMMdd\.\l\o\g"/>
        <param name="StaticLogFileName" value="false"/>
        <layout type="log4net.Layout.PatternLayout">
            <param name="ConversionPattern" value="%date{HH:mm:ss} %C::%M [%-5level] - %message%newline"/>
        </layout>
    </appender>
    <root>
        <level value="ALL"/>
        <appender-ref ref="RollingFileAppender"/>
    </root>
</log4net>

Here is my log4net initialization:

        // Logging for the application
    private static ILog mlog = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);

    protected void Application_Start(object sender, EventArgs e)
    {
        try
        {
            // Start the configuration of the Logging
            XmlConfigurator.Configure();

            mlog.Info("Started logging for the TestApp Application.");
        }
        catch (Exception ex)
        {
            throw;
        }
    }

Any help would be greatly appreciated.

Thanks,

Jim

+1  A: 

If it works in dev and staging environments I'd start by suspecting permissions. See if your 3.5 app can write to a file in the same location as the log4net output.

Joe
Joe, thanks for pointing me in the right direction. After doing this it pointed me to of course permissions. It wasn't file permissions but the ISP had the 1.1 .net at "Full" trust and the .net 3.5 at "Medium" trust. I changed it in the Framework\Config\web.config file and voila!!Sometimes I can't believe how you can get pidgeon holed into thinking one way and it just takes some one to pull you back just a bit and point you in the right direction. Thanks!!
Jim P