Code Coverage by Clover.NET

Re: BUG: targets async="true" ignored identity impersonate

by sideout :: Rate this Message:

Reply to Author | View in Thread

Scratch that, my config change wasn't picked up for some reason.  Even the AsyncWrapper doesn't impersonate without having an impersonatingwrapper.

Also I'm finding that if I try to load the page again while the lazy writer is still retrying (I have a retrying wrapper inside the asyncwrapper), it waits for the batch to finish before letting me in.  Maybe this is required for thread safety or something but it makes the async not so much async...

I can tell the lazy writer is in the middle of writer from the debugging log when I put nlog in debug mode and because I see the following in my debug window:

A first chance exception of type 'System.UnauthorizedAccessException' occurred in mscorlib.dll
A first chance exception of type 'System.UnauthorizedAccessException' occurred in mscorlib.dll
A first chance exception of type 'System.UnauthorizedAccessException' occurred in mscorlib.dll
A first chance exception of type 'System.UnauthorizedAccessException' occurred in mscorlib.dll
A first chance exception of type 'System.UnauthorizedAccessException' occurred in NLog.DLL

and in my debug log:

2008-04-11 17:00:00.2757 Warn Error while writing to 'f3:FileTarget': System.UnauthorizedAccessException: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
   at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo)
   at System.Runtime.InteropServices.Marshal.ThrowExceptionForHR(Int32 errorCode)
   at NLog.Internal.FileAppenders.BaseFileAppender.WindowsCreateFile(String fileName, Boolean allowConcurrentWrite)
   at NLog.Internal.FileAppenders.BaseFileAppender.TryCreateFileStream(Boolean allowConcurrentWrite)
   at NLog.Internal.FileAppenders.BaseFileAppender.CreateFileStream(Boolean allowConcurrentWrite)
   at NLog.Internal.FileAppenders.RetryingMultiProcessFileAppender.Write(Byte[] bytes)
   at NLog.Targets.FileTarget.WriteToFile(String fileName, Byte[] bytes, Boolean justData)
   at NLog.Targets.FileTarget.Write(LogEventInfo logEvent)
   at NLog.Targets.Wrappers.RetryingTargetWrapper.Write(LogEventInfo logEvent)
2008-04-11 17:00:00.7767 Warn Retry #1
2008-04-11 17:00:00.7917 Warn Error while writing to 'f3:FileTarget': System.UnauthorizedAccessException: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
   at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo)
   at System.Runtime.InteropServices.Marshal.ThrowExceptionForHR(Int32 errorCode)
   at NLog.Internal.FileAppenders.BaseFileAppender.WindowsCreateFile(String fileName, Boolean allowConcurrentWrite)
   at NLog.Internal.FileAppenders.BaseFileAppender.TryCreateFileStream(Boolean allowConcurrentWrite)
   at NLog.Internal.FileAppenders.BaseFileAppender.CreateFileStream(Boolean allowConcurrentWrite)
   at NLog.Internal.FileAppenders.RetryingMultiProcessFileAppender.Write(Byte[] bytes)
   at NLog.Targets.FileTarget.WriteToFile(String fileName, Byte[] bytes, Boolean justData)
   at NLog.Targets.FileTarget.Write(LogEventInfo logEvent)
   at NLog.Targets.Wrappers.RetryingTargetWrapper.Write(LogEventInfo logEvent)
2008-04-11 17:00:01.2927 Warn Retry #2
2008-04-11 17:00:01.3077 Warn Error while writing to 'f3:FileTarget': System.UnauthorizedAccessException: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
   at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo)
   at System.Runtime.InteropServices.Marshal.ThrowExceptionForHR(Int32 errorCode)
   at NLog.Internal.FileAppenders.BaseFileAppender.WindowsCreateFile(String fileName, Boolean allowConcurrentWrite)
   at NLog.Internal.FileAppenders.BaseFileAppender.TryCreateFileStream(Boolean allowConcurrentWrite)
   at NLog.Internal.FileAppenders.BaseFileAppender.CreateFileStream(Boolean allowConcurrentWrite)
   at NLog.Internal.FileAppenders.RetryingMultiProcessFileAppender.Write(Byte[] bytes)
   at NLog.Targets.FileTarget.WriteToFile(String fileName, Byte[] bytes, Boolean justData)
   at NLog.Targets.FileTarget.Write(LogEventInfo logEvent)
   at NLog.Targets.Wrappers.RetryingTargetWrapper.Write(LogEventInfo logEvent)
2008-04-11 17:00:01.8087 Warn Retry #3
2008-04-11 17:00:01.8197 Warn Error while writing to 'f3:FileTarget': System.UnauthorizedAccessException: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
   at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo)
   at System.Runtime.InteropServices.Marshal.ThrowExceptionForHR(Int32 errorCode)
   at NLog.Internal.FileAppenders.BaseFileAppender.WindowsCreateFile(String fileName, Boolean allowConcurrentWrite)
   at NLog.Internal.FileAppenders.BaseFileAppender.TryCreateFileStream(Boolean allowConcurrentWrite)
   at NLog.Internal.FileAppenders.BaseFileAppender.CreateFileStream(Boolean allowConcurrentWrite)
   at NLog.Internal.FileAppenders.RetryingMultiProcessFileAppender.Write(Byte[] bytes)
   at NLog.Targets.FileTarget.WriteToFile(String fileName, Byte[] bytes, Boolean justData)
   at NLog.Targets.FileTarget.Write(LogEventInfo logEvent)
   at NLog.Targets.Wrappers.RetryingTargetWrapper.Write(LogEventInfo logEvent)
2008-04-11 17:00:02.3197 Warn Retry #4
2008-04-11 17:00:02.3347 Warn Error while writing to 'f3:FileTarget': System.UnauthorizedAccessException: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
   at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo)
   at System.Runtime.InteropServices.Marshal.ThrowExceptionForHR(Int32 errorCode)
   at NLog.Internal.FileAppenders.BaseFileAppender.WindowsCreateFile(String fileName, Boolean allowConcurrentWrite)
   at NLog.Internal.FileAppenders.BaseFileAppender.TryCreateFileStream(Boolean allowConcurrentWrite)
   at NLog.Internal.FileAppenders.BaseFileAppender.CreateFileStream(Boolean allowConcurrentWrite)
   at NLog.Internal.FileAppenders.RetryingMultiProcessFileAppender.Write(Byte[] bytes)
   at NLog.Targets.FileTarget.WriteToFile(String fileName, Byte[] bytes, Boolean justData)
   at NLog.Targets.FileTarget.Write(LogEventInfo logEvent)
   at NLog.Targets.Wrappers.RetryingTargetWrapper.Write(LogEventInfo logEvent)
2008-04-11 17:00:02.3347 Error Error in lazy writer timer procedure: System.UnauthorizedAccessException: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
   at NLog.Targets.Wrappers.RetryingTargetWrapper.Write(LogEventInfo logEvent)
   at NLog.Target.Write(LogEventInfo[] logEvents)
   at NLog.Targets.Wrappers.AsyncTargetWrapper.LazyWriterTimerCallback(Object state)

If I move the retrywrapper outside the asyncwrapper it doesn't retry at all.

If I take out the retrywrapper I only got this message while the lazy writer is working and because I don't have a delay on retry it's hard to tell if it's making me wait or not.  Seems like not if I had to guess.

A first chance exception of type 'System.UnauthorizedAccessException' occurred in mscorlib.dll

2008-04-11 16:48:24.9957 Error Error in lazy writer timer procedure: System.UnauthorizedAccessException: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
   at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo)
   at System.Runtime.InteropServices.Marshal.ThrowExceptionForHR(Int32 errorCode)
   at NLog.Internal.FileAppenders.BaseFileAppender.WindowsCreateFile(String fileName, Boolean allowConcurrentWrite)
   at NLog.Internal.FileAppenders.BaseFileAppender.TryCreateFileStream(Boolean allowConcurrentWrite)
   at NLog.Internal.FileAppenders.BaseFileAppender.CreateFileStream(Boolean allowConcurrentWrite)
   at NLog.Internal.FileAppenders.RetryingMultiProcessFileAppender.Write(Byte[] bytes)
   at NLog.Targets.FileTarget.WriteToFile(String fileName, Byte[] bytes, Boolean justData)
   at NLog.Targets.FileTarget.Write(LogEventInfo[] logEvents)
   at NLog.Targets.Wrappers.AsyncTargetWrapper.LazyWriterTimerCallback(Object state)

I don't see any exceptions from NLog.dll in this case.  I wonder if there's also a problem with the retry in an async.

I'm working in ASP.NET 3.5 in VS2008.

This is a snippet of my config:

  <targets>
    <target name="aspnettrace" xsi:type="ASPNetTrace" />
    <target name="debug" xsi:type="Debugger" />
    <target xsi:type="AsyncWrapper" batchSize="100" overflowAction="Grow" queueLimit="100000" name="file">
      <target name="f2" xsi:type="RetryingWrapper" retryCount="5" retryDelayMilliseconds="500">
      <!--<target xsi:type="ImpersonatingWrapper" impersonationLevel="Impersonation" username="username" password="password" name="impWrapper">-->

          <target name="f3" xsi:type="File" fileName="\\otherbox\logs\${shortdate}.txt" concurrentWriteAttemptDelay="100"/>
        <!--</target>-->
      </target>
    </target>
  </targets>
  <rules>
    <logger name="*" minLevel="Debug" appendTo="aspnettrace, file, debug"/>
  </rules>
LightInTheBox - Buy quality products at wholesale price