How can I get it to log InnerExceptions?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

How can I get it to log InnerExceptions?

David Thielen-2

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

 

Reply | Threaded
Open this post in threaded view
|

RE: How can I get it to log InnerExceptions?

David Thielen-2

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 <[hidden email]>
Sent: Tuesday, May 7, 2019 9:21 AM
To: [hidden email]
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