Uploaded image for project: 'Log4net'
  1. Log4net
  2. LOG4NET-266

AdoNetAppender does not work on a IIS 7 website using Windows authentication

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Critical
    • Resolution: Fixed
    • Affects Version/s: 1.2.10
    • Fix Version/s: 1.2.12
    • Component/s: Appenders
    • Labels:
      None
    • Environment:
      Windows Server 2008, IIS 7, ASP.Net Framework v4.0, Sql Server 2008, Windows Authentication Activated

      Description

      When the Windows Authentication is deactivated, the AdoNetAppender works properly.

      Howerver, once the Windows authentication is activated, the AdoNetAppender start working properly and then, after a few seconds, it is aborted and the following error message is retrieved:

      log4net:ERROR [AdoNetAppender] Failed in DoAppend
      System.ObjectDisposedException: Safe handle has been closed
      at System.Runtime.InteropServices.SafeHandle.DangerousAddRef(Boolean& success)
      at System.StubHelpers.StubHelpers.SafeHandleAddRef(SafeHandle pHandle, Boolean& success)
      at Microsoft.Win32.Win32Native.GetTokenInformation(SafeTokenHandle TokenHandle, UInt32 TokenInformationClass, SafeLocalAllocHandle TokenInformation, UInt32 TokenInformationLength, UInt32& ReturnLength)
      at System.Security.Principal.WindowsIdentity.GetTokenInformation(SafeTokenHandle tokenHandle, TokenInformationClass tokenInformationClass)
      at System.Security.Principal.WindowsIdentity.get_User()
      at System.Security.Principal.WindowsIdentity.GetName()
      at System.Security.Principal.WindowsIdentity.get_Name()
      at log4net.Core.LoggingEvent.get_Identity()
      at log4net.Core.LoggingEvent.FixVolatileData(FixFlags flags)
      at log4net.Appender.BufferingAppenderSkeleton.Append(LoggingEvent loggingEvent)
      at log4net.Appender.AppenderSkeleton.DoAppend(LoggingEvent loggingEvent)

      See below the settings of the appender. Various options (i.e. Securitycontext ) have also been tested in vain.

      <appender name="AdoNetAppender_SqlServer" type="log4net.Appender.AdoNetAppender">
      <bufferSize value="1" />
      <connectionType value="System.Data.SqlClient.SqlConnection, System.Data, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
      <connectionString value="data source=WWWWWW;initial catalog=XXXXX;integrated security=false;persist security info=True;User ID=sa;Password=YYYYYYYY" />
      <commandText value="sp_LOG_Insert"/>
      <commandType value="StoredProcedure" />
      <parameter>
      <parameterName value="@DATE" />
      <dbType value="DateTime" />
      <layout type="log4net.Layout.PatternLayout" value="%date

      {yyyy'-'MM'-'dd HH':'mm':'ss'.'fff}

      " />
      </parameter>
      <parameter>
      <parameterName value="@THREAD" />
      <dbType value="String" />
      <size value="255" />
      <layout type="log4net.Layout.PatternLayout" value="%thread" />
      </parameter>
      <parameter>
      <parameterName value="@LEVEL" />
      <dbType value="String" />
      <size value="50" />
      <layout type="log4net.Layout.PatternLayout" value="%level" />
      </parameter>
      <parameter>
      <parameterName value="@LOGGER" />
      <dbType value="String" />
      <size value="255" />
      <layout type="log4net.Layout.PatternLayout" value="%logger" />
      </parameter>
      <parameter>
      <parameterName value="@MESSAGE" />
      <dbType value="String" />
      <size value="8000" />
      <layout type="log4net.Layout.PatternLayout" value="%message" />
      </parameter>

      </appender>

        Attachments

        1. LoggingEvent.cs
          46 kB
          Johannes Krackowizer

          Issue Links

            Activity

              People

              • Assignee:
                nachbarslumpi Dominik Psenner
                Reporter:
                kaider Kaider
              • Votes:
                1 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Time Tracking

                  Estimated:
                  Original Estimate - 4h
                  4h
                  Remaining:
                  Remaining Estimate - 4h
                  4h
                  Logged:
                  Time Spent - Not Specified
                  Not Specified