Discussion:
Exception Logging
Annette Sündermann
2004-12-08 14:24:44 UTC
Permalink
I am using log4net 1.2.0 beta 8.

According to the documentation, the following code:

this.logger.Error ( "exception observed!", new Exception("I am an Exception") );

should

'Log a message object with the ERROR level including the stack trace of the Exception passed as a parameter.'

On my logfile, I only find the following text:

2004-12-08 15:21:51,171 ERROR FormPoc.Form1_Load[376]
exception observed!
Exception: System.Exception
Message: I am an Exception

No StackTrace is logged.

My log4net configuration is:
<log4net>
<!-- Define a Rolling File Appender -->
<appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender">
<param name="File" value="G:/MTraceReports/MReport/log/Poc.log"/>
<param name="AppendToFile" value="true"/>
<param name="RollingStyle" value="Size"/>
<param name="MaxSizeRollBackups" value="10"/>
<param name="MaximumFileSize" value="1MB"/>
<param name="StaticLogFileName" value="true"/>
<layout type="log4net.Layout.PatternLayout">
<param name="ConversionPattern" value="%d{ISO8601} %-5p %C{1}.%M[%L]%n%m%n"/>
</layout>
</appender>
<!-- Set root logger level to DEBUG and add the RollingFileAppender -->
<root>
<level value="ALL"/>
<appender-ref ref="RollingFileAppender"/>
</root>
</log4net>

What is the reason for the missing StackTrace?
Marcel Kunz
2004-12-08 14:36:44 UTC
Permalink
Because your StackTrace is Null/Nothing. As long as you don't throw the exception the StackTrace will be 'Null'.

Tschüss
Marcel


Vitodata AG, Marcel Kunz
Dipl. IT Ing. FH
Deisrütistrasse 10, CH-8472 Ohringen
Telefon +41 (0)52 320 55 55, Fax +41 (0)52 320 55 66
Telefon direkt +41 (0)52 320 56 64
mailto:***@vitodata.ch



-----Original Message-----
From: Annette Sündermann [mailto:***@sycada.com]
Sent: Wednesday, December 08, 2004 3:25 PM
To: log4net-***@logging.apache.org
Subject: Exception Logging


I am using log4net 1.2.0 beta 8.

According to the documentation, the following code:

this.logger.Error ( "exception observed!", new Exception("I am an Exception") );

should

'Log a message object with the ERROR level including the stack trace of the Exception passed as a parameter.'

On my logfile, I only find the following text:

2004-12-08 15:21:51,171 ERROR FormPoc.Form1_Load[376]
exception observed!
Exception: System.Exception
Message: I am an Exception

No StackTrace is logged.

My log4net configuration is:
<log4net>
<!-- Define a Rolling File Appender -->
<appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender">
<param name="File" value="G:/MTraceReports/MReport/log/Poc.log"/>
<param name="AppendToFile" value="true"/>
<param name="RollingStyle" value="Size"/>
<param name="MaxSizeRollBackups" value="10"/>
<param name="MaximumFileSize" value="1MB"/>
<param name="StaticLogFileName" value="true"/>
<layout type="log4net.Layout.PatternLayout">
<param name="ConversionPattern" value="%d{ISO8601} %-5p %C{1}.%M[%L]%n%m%n"/>
</layout>
</appender>
<!-- Set root logger level to DEBUG and add the RollingFileAppender -->
<root>
<level value="ALL"/>
<appender-ref ref="RollingFileAppender"/>
</root>
</log4net>

What is the reason for the missing StackTrace?

Loading...