You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4net-user@logging.apache.org by David Thielen <da...@windward.net> on 2019/05/07 15:20:42 UTC

How can I get it to log InnerExceptions?

What I want is basic, to have the log display the InnerException(s) for an exception and the call stack for each.

My configuration is:

<log4net debug="false">

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

           <param name="File" value="C:\temp\DotNetEngine.log" />

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

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

           <param name="MaximumFileSize" value="500KB" />

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

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

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

                <param name="ConversionPattern" value="%date [%thread] %level %logger - %message%exception%newline" />

           </layout>

     </appender>

     <root>

           <level value="debug" />

           <appender-ref ref="RollingFileAppender" />

     </root>

</log4net>

My code is:

logWriter.Error("RunReport", ex);



But all I get is: 2019-05-06 16:28:28,042 [1] ERROR RunReport.net.windward.samples.RunReport - RunReportnet.windward.env.DataSourceException: Could not load file: c:\test\xyz.docx; subtype=INVALID_FILENAME;

And the above exception does have an InnerException (verified with the debugger).

I am using log4net 2.0.8 which is the latest


RE: How can I get it to log InnerExceptions?

Posted by David Thielen <da...@windward.net>.
Never mind - the issue for me is we're using IKVM to convert Java to .NET. And Java Exception.toString() does not print everything out.


From: David Thielen <da...@windward.net>
Sent: Tuesday, May 7, 2019 9:21 AM
To: log4net-user@logging.apache.org
Subject: How can I get it to log InnerExceptions?


What I want is basic, to have the log display the InnerException(s) for an exception and the call stack for each.

My configuration is:

<log4net debug="false">

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

           <param name="File" value="C:\temp\DotNetEngine.log" />

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

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

           <param name="MaximumFileSize" value="500KB" />

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

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

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

                <param name="ConversionPattern" value="%date [%thread] %level %logger - %message%exception%newline" />

           </layout>

     </appender>

     <root>

           <level value="debug" />

           <appender-ref ref="RollingFileAppender" />

     </root>

</log4net>

My code is:

logWriter.Error("RunReport", ex);



But all I get is: 2019-05-06 16:28:28,042 [1] ERROR RunReport.net.windward.samples.RunReport - RunReportnet.windward.env.DataSourceException: Could not load file: c:\test\xyz.docx; subtype=INVALID_FILENAME;

And the above exception does have an InnerException (verified with the debugger).

I am using log4net 2.0.8 which is the latest