You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4net-dev@logging.apache.org by "HJ (JIRA)" <ji...@apache.org> on 2007/09/25 16:28:51 UTC

[jira] Created: (LOG4NET-121) ASP.NET web application using log4net results in a first chance exception of type 'System.Threading.ThreadAbortException'

ASP.NET web application using log4net results in a first chance exception of type 'System.Threading.ThreadAbortException' 
--------------------------------------------------------------------------------------------------------------------------

                 Key: LOG4NET-121
                 URL: https://issues.apache.org/jira/browse/LOG4NET-121
             Project: Log4net
          Issue Type: Bug
          Components: Core
    Affects Versions: 1.2.9
         Environment: Windows XP Professional running Visual Studio .NET 2003
            Reporter: HJ


I have created a simple ASP.NET webapplication that just prints a statement to a log file. I ran this web application in Visual Studio debugger and the application crashes on the log statement with error message shown below. I use a seperate configuration file to configure log4net for my application as I don't want to use web.config or applicationName.exe.config file and want to stick to a seperate log configuration file. Attached below is the log config file that I'm using and the snippet of C# code that I'm using to initialize logger. I have given ASPNET user full permissions on "D:\Logs" directory.

I will appreciate your early help.


Log configuration file:
-----------------------------------
<?xml version="1.0" encoding="utf-8" ?> 
<!-- .NET Application configuration file -->

<configuration>

	<!-- Register the section handler for the log4net section -->
	<configSections>
		<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net" />
	</configSections>

	<!-- Enable internal debugging in log4net -->
	<appSettings>
		<!-- To enable internal log4net logging specify the 
		     following appSettings key -->
		     
		<!-- <add key="log4net.Internal.Debug" value="true"/> -->
		
	</appSettings>

  	
	<log4net>

      		<appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender">

      			
				<param name="File" value="D:\Logs\logfile.txt" />

      			<param name="AppendToFile" value="true" />

      			<param name="MaxSizeRollBackups" value="15" />

      			<param name="MaximumFileSize" value="10000000" />

      			<param name="RollingStyle" value="Size" />

     			<!-- evaluator type="log4net.spi.LevelEvaluator">

            			<threshold value="DEBUG"/>

      			</evaluator -->

      			<layout type="log4net.Layout.PatternLayout">

        			<param name="ConversionPattern" value="%d [%t]%-5p [%c] - %m%n" />

      			</layout>

    		</appender>

    		<root>

      			<priority value="DEBUG" />

    		</root>


    		<logger name="TestLogger">

      			<level value="DEBUG" />

      				<appender-ref ref="RollingFileAppender" />
      				
    		</logger>

    </log4net>

</configuration>

-------------------------------



C# code sample showing how I intialize the logger:
------------------------------------------------------------------

public class MySample
{
      private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger("TestLogger");

      public void InitializeLogger()
     {
           log4net.Config.XmlConfigurator.ConfigureAndWatch(m_LoggerConfigFileLocation);
           m_log.Info("Logging to the file");
     }
     
}

-------------------------------------------




Debug Output error message in Visual Studio .net 2003:
----------------------------------------------------------------------------------
A first chance exception of type 'System.Threading.ThreadAbortException' occurred in mscorlib.dll

Additional information: Thread was being aborted.

The program '[5232] aspnet_wp.exe: DefaultDomain' has exited with code 0 (0x0).


Callstack:
--------------------------------
>	mscorlib.dll!System.UnloadThreadWorker.Unload(System.AppDomain domain) + 0x126 bytes	
 	mscorlib.dll!System.UnloadWorker.Unload(System.AppDomain domain) + 0x65 bytes	
 	mscorlib.dll!System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(System.Runtime.Remoting.Messaging.IMessage msg, int methodPtr, bool fExecuteInContext) + 0x30b bytes	
 	mscorlib.dll!System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(System.Runtime.Remoting.Messaging.IMessage msg) + 0x9 bytes	
 	mscorlib.dll!System.Runtime.Remoting.Messaging.ServerObjectTerminatorSink.SyncProcessMessage(System.Runtime.Remoting.Messaging.IMessage reqMsg) + 0x12c bytes	
 	mscorlib.dll!System.Runtime.Remoting.Messaging.ServerContextTerminatorSink.SyncProcessMessage(System.Runtime.Remoting.Messaging.IMessage reqMsg) + 0x1b3 bytes	
 	mscorlib.dll!System.Runtime.Remoting.Channels.CrossContextChannel.SyncProcessMessage(System.Runtime.Remoting.Messaging.IMessage reqMsg) + 0x209 bytes	
 	mscorlib.dll!System.Runtime.Remoting.Channels.ChannelServices.SyncDispatchMessage(System.Runtime.Remoting.Messaging.IMessage msg) + 0xe6 bytes	
 	mscorlib.dll!System.Runtime.Remoting.Channels.CrossAppDomainSink.DoDispatch(byte[] reqStmBuff, System.Runtime.Remoting.Messaging.SmuggledMethodCallMessage smuggledMcm, System.Runtime.Remoting.Messaging.SmuggledMethodReturnMessage smuggledMrm) + 0x70 bytes	
 	mscorlib.dll!System.Runtime.Remoting.Channels.CrossAppDomainSink.DoTransitionDispatch(byte[] reqStmBuff, System.Runtime.Remoting.Messaging.SmuggledMethodCallMessage smuggledMcm, System.Runtime.Remoting.Messaging.SmuggledMethodReturnMessage smuggledMrm) + 0x6e bytes	
 	mscorlib.dll!System.Runtime.Remoting.Channels.CrossAppDomainSink.SyncProcessMessage(System.Runtime.Remoting.Messaging.IMessage reqMsg) + 0x1e1 bytes	
 	mscorlib.dll!System.Runtime.Remoting.Proxies.RemotingProxy.CallProcessMessage(System.Runtime.Remoting.Messaging.IMessageSink ms, System.Runtime.Remoting.Messaging.IMessage reqMsg, System.Runtime.Remoting.Contexts.ArrayWithSize proxySinks, System.Threading.Thread currentThread, System.Runtime.Remoting.Contexts.Context currentContext, bool bSkippingContextChain) + 0x62 bytes	
 	mscorlib.dll!System.Runtime.Remoting.Proxies.RemotingProxy.InternalInvoke(System.Runtime.Remoting.Messaging.IMethodCallMessage reqMcmMsg, bool useDispatchMessage, int callType) + 0x28d bytes	
 	mscorlib.dll!System.Runtime.Remoting.Proxies.RemotingProxy.Invoke(System.Runtime.Remoting.Messaging.IMessage reqMsg) + 0x113 bytes	
 	mscorlib.dll!System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(System.Runtime.Remoting.Proxies.MessageData msgData, int type) + 0x288 bytes	
 	mscorlib.dll!System.AppDomain.Unload(System.AppDomain domain) + 0x32 bytes	
 	system.web.dll!System.Web.HttpRuntime.ReleaseResourcesAndUnloadAppDomain(System.Object state = <undefined value>) + 0x67 bytes	

------------

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (LOG4NET-121) ASP.NET web application using log4net results in a first chance exception of type 'System.Threading.ThreadAbortException'

Posted by "Ron Grabowski (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/LOG4NET-121?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Ron Grabowski resolved LOG4NET-121.
-----------------------------------

    Resolution: Invalid
      Assignee: Ron Grabowski

It doesn't appear that your issue is a log4net related exception. Log4net doesn't use anything in System.Runtime.Remoting.Messaging or System.Runtime.Remoting.Channels during its initialization process.

If you want to store your configuration in an external file such as log4net.config, that file needs to look like this:

<?xml version="1.0" encoding="utf-8" ?>
<log4net>
 <!-- put your configuration here -->
</log4net>

Your MySample looks strange. Log4net auto-configures itself when it the program executes this line:

 private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger("TestLogger"); 

then you reconfigure log4net using the ConfigreAndWatch. ConfigureAndWatch should be in Application_Start.

I can't reproduce your error.

> ASP.NET web application using log4net results in a first chance exception of type 'System.Threading.ThreadAbortException' 
> --------------------------------------------------------------------------------------------------------------------------
>
>                 Key: LOG4NET-121
>                 URL: https://issues.apache.org/jira/browse/LOG4NET-121
>             Project: Log4net
>          Issue Type: Bug
>          Components: Core
>    Affects Versions: 1.2.9
>         Environment: Windows XP Professional running Visual Studio .NET 2003
>            Reporter: HJ
>            Assignee: Ron Grabowski
>
> I have created a simple ASP.NET webapplication that just prints a statement to a log file. I ran this web application in Visual Studio debugger and the application crashes on the log statement with error message shown below. I use a seperate configuration file to configure log4net for my application as I don't want to use web.config or applicationName.exe.config file and want to stick to a seperate log configuration file. Attached below is the log config file that I'm using and the snippet of C# code that I'm using to initialize logger. I have given ASPNET user full permissions on "D:\Logs" directory.
> I will appreciate your early help.
> Log configuration file:
> -----------------------------------
> <?xml version="1.0" encoding="utf-8" ?> 
> <!-- .NET Application configuration file -->
> <configuration>
> 	<!-- Register the section handler for the log4net section -->
> 	<configSections>
> 		<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net" />
> 	</configSections>
> 	<!-- Enable internal debugging in log4net -->
> 	<appSettings>
> 		<!-- To enable internal log4net logging specify the 
> 		     following appSettings key -->
> 		     
> 		<!-- <add key="log4net.Internal.Debug" value="true"/> -->
> 		
> 	</appSettings>
>   	
> 	<log4net>
>       		<appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender">
>       			
> 				<param name="File" value="D:\Logs\logfile.txt" />
>       			<param name="AppendToFile" value="true" />
>       			<param name="MaxSizeRollBackups" value="15" />
>       			<param name="MaximumFileSize" value="10000000" />
>       			<param name="RollingStyle" value="Size" />
>      			<!-- evaluator type="log4net.spi.LevelEvaluator">
>             			<threshold value="DEBUG"/>
>       			</evaluator -->
>       			<layout type="log4net.Layout.PatternLayout">
>         			<param name="ConversionPattern" value="%d [%t]%-5p [%c] - %m%n" />
>       			</layout>
>     		</appender>
>     		<root>
>       			<priority value="DEBUG" />
>     		</root>
>     		<logger name="TestLogger">
>       			<level value="DEBUG" />
>       				<appender-ref ref="RollingFileAppender" />
>       				
>     		</logger>
>     </log4net>
> </configuration>
> -------------------------------
> C# code sample showing how I intialize the logger:
> ------------------------------------------------------------------
> public class MySample
> {
>       private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger("TestLogger");
>       public void InitializeLogger()
>      {
>            log4net.Config.XmlConfigurator.ConfigureAndWatch(m_LoggerConfigFileLocation);
>            m_log.Info("Logging to the file");
>      }
>      
> }
> -------------------------------------------
> Debug Output error message in Visual Studio .net 2003:
> ----------------------------------------------------------------------------------
> A first chance exception of type 'System.Threading.ThreadAbortException' occurred in mscorlib.dll
> Additional information: Thread was being aborted.
> The program '[5232] aspnet_wp.exe: DefaultDomain' has exited with code 0 (0x0).
> Callstack:
> --------------------------------
> >	mscorlib.dll!System.UnloadThreadWorker.Unload(System.AppDomain domain) + 0x126 bytes	
>  	mscorlib.dll!System.UnloadWorker.Unload(System.AppDomain domain) + 0x65 bytes	
>  	mscorlib.dll!System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(System.Runtime.Remoting.Messaging.IMessage msg, int methodPtr, bool fExecuteInContext) + 0x30b bytes	
>  	mscorlib.dll!System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(System.Runtime.Remoting.Messaging.IMessage msg) + 0x9 bytes	
>  	mscorlib.dll!System.Runtime.Remoting.Messaging.ServerObjectTerminatorSink.SyncProcessMessage(System.Runtime.Remoting.Messaging.IMessage reqMsg) + 0x12c bytes	
>  	mscorlib.dll!System.Runtime.Remoting.Messaging.ServerContextTerminatorSink.SyncProcessMessage(System.Runtime.Remoting.Messaging.IMessage reqMsg) + 0x1b3 bytes	
>  	mscorlib.dll!System.Runtime.Remoting.Channels.CrossContextChannel.SyncProcessMessage(System.Runtime.Remoting.Messaging.IMessage reqMsg) + 0x209 bytes	
>  	mscorlib.dll!System.Runtime.Remoting.Channels.ChannelServices.SyncDispatchMessage(System.Runtime.Remoting.Messaging.IMessage msg) + 0xe6 bytes	
>  	mscorlib.dll!System.Runtime.Remoting.Channels.CrossAppDomainSink.DoDispatch(byte[] reqStmBuff, System.Runtime.Remoting.Messaging.SmuggledMethodCallMessage smuggledMcm, System.Runtime.Remoting.Messaging.SmuggledMethodReturnMessage smuggledMrm) + 0x70 bytes	
>  	mscorlib.dll!System.Runtime.Remoting.Channels.CrossAppDomainSink.DoTransitionDispatch(byte[] reqStmBuff, System.Runtime.Remoting.Messaging.SmuggledMethodCallMessage smuggledMcm, System.Runtime.Remoting.Messaging.SmuggledMethodReturnMessage smuggledMrm) + 0x6e bytes	
>  	mscorlib.dll!System.Runtime.Remoting.Channels.CrossAppDomainSink.SyncProcessMessage(System.Runtime.Remoting.Messaging.IMessage reqMsg) + 0x1e1 bytes	
>  	mscorlib.dll!System.Runtime.Remoting.Proxies.RemotingProxy.CallProcessMessage(System.Runtime.Remoting.Messaging.IMessageSink ms, System.Runtime.Remoting.Messaging.IMessage reqMsg, System.Runtime.Remoting.Contexts.ArrayWithSize proxySinks, System.Threading.Thread currentThread, System.Runtime.Remoting.Contexts.Context currentContext, bool bSkippingContextChain) + 0x62 bytes	
>  	mscorlib.dll!System.Runtime.Remoting.Proxies.RemotingProxy.InternalInvoke(System.Runtime.Remoting.Messaging.IMethodCallMessage reqMcmMsg, bool useDispatchMessage, int callType) + 0x28d bytes	
>  	mscorlib.dll!System.Runtime.Remoting.Proxies.RemotingProxy.Invoke(System.Runtime.Remoting.Messaging.IMessage reqMsg) + 0x113 bytes	
>  	mscorlib.dll!System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(System.Runtime.Remoting.Proxies.MessageData msgData, int type) + 0x288 bytes	
>  	mscorlib.dll!System.AppDomain.Unload(System.AppDomain domain) + 0x32 bytes	
>  	system.web.dll!System.Web.HttpRuntime.ReleaseResourcesAndUnloadAppDomain(System.Object state = <undefined value>) + 0x67 bytes	
> ------------

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.