[
https://issues.apache.org/jira/browse/LOG4NET-363?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Stefan Bodewig resolved LOG4NET-363.
------------------------------------
Resolution: Duplicate
Fix Version/s: 1.2.12
> System.ObjectDisposedException thrown in
> log4net.Layout.XmlLayoutSchemaLog4j.FormatXml ln 47
> --------------------------------------------------------------------------------------------
>
> Key: LOG4NET-363
> URL: https://issues.apache.org/jira/browse/LOG4NET-363
> Project: Log4net
> Issue Type: Bug
> Components: Appenders
> Affects Versions: 1.2.11
> Environment: IIS 7.0
> Reporter: David Perlman
> Priority: Minor
> Labels: nullpointerexception
> Fix For: 1.2.12
>
>
> On line 47 in XmlLayoutSchemaLog4j there is a reference to the
> LoggingEvent.Identity property. If this call is made after the web request is
> finished (from a different thread) the logger throws (below the exception is
> my sad workaround):
> log4net:ERROR [UdpAppender] ErrorCode: WriteFailure. Unable to send logging
> event to remote host ------- on port ----.
> System.ObjectDisposedException: Safe handle has been closed
> at System.Runtime.InteropServices.SafeHandle.DangerousAddRef(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.Layout.XmlLayoutSchemaLog4j.FormatXml(XmlWriter writer,
> LoggingEvent loggingEvent)
> at log4net.Layout.XmlLayoutBase.Format(TextWriter writer, LoggingEvent
> loggingEvent)
> at log4net.Appender.AppenderSkeleton.RenderLoggingEvent(LoggingEvent
> loggingEvent)
> at log4net.Appender.UdpAppender.Append(LoggingEvent loggingEvent)
> Workaround -----
> // translate identity name
> // When logging on a thread that continues (asynchronously) after
> the web request is finished this will throw the logging
> try
> {
> if (loggingEvent.Identity != null &&
> loggingEvent.Identity.Length > 0 &&
>
> loggingEvent.LookupProperty(LoggingEvent.IdentityProperty) == null)
> {
>
> loggingEvent.GetProperties()[LoggingEvent.IdentityProperty] =
> loggingEvent.Identity ?? "identity lost";
> }
> }
> catch { }
--
This message was sent by Atlassian JIRA
(v6.1#6144)