logging-log4net-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "NN (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (LOG4NET-484) System.ObjectDisposedException with FileAppender+InterProcessLock
Date Tue, 27 Oct 2015 08:50:27 GMT

     [ https://issues.apache.org/jira/browse/LOG4NET-484?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

NN updated LOG4NET-484:
-----------------------
    Description: 
Configure lockingModel for InterProcessLock with RollingFileAppender.

{code:xml|title=app.config}
<?xml version="1.0" encoding="utf-8"?>
<configuration>
	<configSections>
		<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net"
/>
	</configSections>
	<log4net>
		<appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender">
			<file type="log4net.Util.PatternString" value="test.log" />
			<encoding value="utf-8" />
			<appendToFile value="true"/>
			<rollingStyle value="Size"/>
			<maxSizeRollBackups value="10"/>
			<maximumFileSize value="1"/>
			<staticLogFileName value="true"/>
			<layout type="log4net.Layout.PatternLayout">
				<conversionPattern value="%d [%t] %-5p %c{2} - %m%n"/>
			</layout>
			<lockingModel type="log4net.Appender.FileAppender+InterProcessLock" />
		</appender>
		<root>
			<level value="INFO"/>
			<appender-ref ref="RollingFileAppender"/>
		</root>
	</log4net>
</configuration>
{code}

Make a log with roll :

{code:title=Program.cs}
using log4net;

namespace ConsoleApplication131
{
	class Program
	{
		static void Main(string[] args)
		{
			var log = LogManager.GetLogger(typeof(Program));
			log.Info("A");
			log.Info("A");
		}
	}
}
{code}

You get this one roll:

{noformat}
log4net:ERROR Failed to Close appender [RollingFileAppender]
System.ObjectDisposedException: Safe handle has been closed
   at System.Threading.WaitHandle.WaitOneNative(SafeWaitHandle waitHandle, UInt32 millisecondsTimeout,
Boolean hasThreadAffinity, Boolean exitContext)
   at System.Threading.WaitHandle.WaitOne(Int64 timeout, Boolean exitContext)
   at log4net.Appender.FileAppender.InterProcessLock.AcquireLock()
   at log4net.Appender.FileAppender.LockingStream.AcquireLock()
   at log4net.Appender.FileAppender.WriteFooter()
   at log4net.Appender.TextWriterAppender.WriteFooterAndCloseWriter()
   at log4net.Appender.TextWriterAppender.Reset()
   at log4net.Appender.FileAppender.Reset()
   at log4net.Appender.TextWriterAppender.OnClose()
   at log4net.Appender.AppenderSkeleton.Close()
   at log4net.Util.AppenderAttachedImpl.RemoveAllAppenders()
{noformat}

  was:
Configure lockingModel for InterProcessLock with RollingFileAppender.

{code:xml|title=app.config}
<?xml version="1.0" encoding="utf-8"?>
<configuration>
	<configSections>
		<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net"
/>
	</configSections>
	<log4net>
		<appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender">
			<file type="log4net.Util.PatternString" value="test.log" />
			<encoding value="utf-8" />
			<appendToFile value="true"/>
			<rollingStyle value="Size"/>
			<maxSizeRollBackups value="10"/>
			<maximumFileSize value="1"/>
			<staticLogFileName value="true"/>
			<layout type="log4net.Layout.PatternLayout">
				<conversionPattern value="%d [%t] %-5p %c{2} - %m%n"/>
			</layout>
			<lockingModel type="log4net.Appender.FileAppender+InterProcessLock" />
		</appender>
		<root>
			<level value="INFO"/>
			<appender-ref ref="RollingFileAppender"/>
		</root>
	</log4net>
</configuration>
{code}

Make a log with roll :

{code:title=Program.cs}
using log4net;

namespace ConsoleApplication131
{
	class Program
	{
		static void Main(string[] args)
		{
			var log = LogManager.GetLogger(typeof(Program));
			log.Info("A");
			log.Info("A");
		}
	}
}
{code}

You get this one roll:

{noformat}
log4net:ERROR Failed to Close appender [RollingFileAppender]
System.ObjectDisposedException: Safe handle has been closed
   at System.Threading.WaitHandle.WaitOneNative(SafeWaitHandle waitHandle, UInt3
2 millisecondsTimeout, Boolean hasThreadAffinity, Boolean exitContext)
   at System.Threading.WaitHandle.WaitOne(Int64 timeout, Boolean exitContext)
   at log4net.Appender.FileAppender.InterProcessLock.AcquireLock()
   at log4net.Appender.FileAppender.LockingStream.AcquireLock()
   at log4net.Appender.FileAppender.WriteFooter()
   at log4net.Appender.TextWriterAppender.WriteFooterAndCloseWriter()
   at log4net.Appender.TextWriterAppender.Reset()
   at log4net.Appender.FileAppender.Reset()
   at log4net.Appender.TextWriterAppender.OnClose()
   at log4net.Appender.AppenderSkeleton.Close()
   at log4net.Util.AppenderAttachedImpl.RemoveAllAppenders()
{noformat}


> System.ObjectDisposedException with FileAppender+InterProcessLock
> -----------------------------------------------------------------
>
>                 Key: LOG4NET-484
>                 URL: https://issues.apache.org/jira/browse/LOG4NET-484
>             Project: Log4net
>          Issue Type: Bug
>          Components: Appenders
>    Affects Versions: 1.2.13, 1.2.14, 1.2.15, 1.3.0
>            Reporter: NN
>            Priority: Blocker
>
> Configure lockingModel for InterProcessLock with RollingFileAppender.
> {code:xml|title=app.config}
> <?xml version="1.0" encoding="utf-8"?>
> <configuration>
> 	<configSections>
> 		<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,
log4net" />
> 	</configSections>
> 	<log4net>
> 		<appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender">
> 			<file type="log4net.Util.PatternString" value="test.log" />
> 			<encoding value="utf-8" />
> 			<appendToFile value="true"/>
> 			<rollingStyle value="Size"/>
> 			<maxSizeRollBackups value="10"/>
> 			<maximumFileSize value="1"/>
> 			<staticLogFileName value="true"/>
> 			<layout type="log4net.Layout.PatternLayout">
> 				<conversionPattern value="%d [%t] %-5p %c{2} - %m%n"/>
> 			</layout>
> 			<lockingModel type="log4net.Appender.FileAppender+InterProcessLock" />
> 		</appender>
> 		<root>
> 			<level value="INFO"/>
> 			<appender-ref ref="RollingFileAppender"/>
> 		</root>
> 	</log4net>
> </configuration>
> {code}
> Make a log with roll :
> {code:title=Program.cs}
> using log4net;
> namespace ConsoleApplication131
> {
> 	class Program
> 	{
> 		static void Main(string[] args)
> 		{
> 			var log = LogManager.GetLogger(typeof(Program));
> 			log.Info("A");
> 			log.Info("A");
> 		}
> 	}
> }
> {code}
> You get this one roll:
> {noformat}
> log4net:ERROR Failed to Close appender [RollingFileAppender]
> System.ObjectDisposedException: Safe handle has been closed
>    at System.Threading.WaitHandle.WaitOneNative(SafeWaitHandle waitHandle, UInt32 millisecondsTimeout,
Boolean hasThreadAffinity, Boolean exitContext)
>    at System.Threading.WaitHandle.WaitOne(Int64 timeout, Boolean exitContext)
>    at log4net.Appender.FileAppender.InterProcessLock.AcquireLock()
>    at log4net.Appender.FileAppender.LockingStream.AcquireLock()
>    at log4net.Appender.FileAppender.WriteFooter()
>    at log4net.Appender.TextWriterAppender.WriteFooterAndCloseWriter()
>    at log4net.Appender.TextWriterAppender.Reset()
>    at log4net.Appender.FileAppender.Reset()
>    at log4net.Appender.TextWriterAppender.OnClose()
>    at log4net.Appender.AppenderSkeleton.Close()
>    at log4net.Util.AppenderAttachedImpl.RemoveAllAppenders()
> {noformat}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message