I am trying to log exceptions that come from IKVM.OpenJDK.Jdbc assembly. One exception that occurs is java.sql.SQLException
(and subclasses). log4Net seems to trip up over this because java.sql.SQLException
implements IEnumerable
and the implementation of that just returns itself. I have stepped through the log4net code for this and it looks like log4net says something like:
"Here is a SQLException to log. Does it contain any information that I should log? Oh, yes it does. There is an IEnumerable, I had better log the stuff inside the IEnumerable. So what is in that IEnumerable? Oh, look it is a SQLException to log. Does it contain any that I should log? Oh, yes it does. There is an IEnumerable, I had better log the stuff inside the IEnumerable. So what is in that IEnumerable? Oh, look it is a SQLException..."
Eventually we get a StackOverflowException
.
Has anybody had and solved this problem before?
Minimal Verifiable Complete Example:
static void Main(string[] args)
{
java.sql.SQLException ex = new java.sql.SQLException();
log4net.Config.BasicConfigurator.Configure();
log4net.ILog logger = log4net.LogManager.GetLogger("foo");
logger.Error("This exception overflows the stack -> ", ex); // Exception here
Console.WriteLine("Finished. Press any key...");
Console.ReadKey();
}
And the packages.config I used to get the right NuGets to make it compile (NuGet source = https://www.nuget.org/api/v2/):
<packages>
<package id="log4net" version="2.0.5" targetFramework="net452" />
<package id="IKVM.OpenJDK.Jdbc" version="7.2.4630.5" targetFramework="net452" />
<!-- The packages below are dependencies from manually getting the packages above. -->
<package id="IKVM.OpenJDK.Charsets" version="7.2.4630.5" targetFramework="net452" />
<package id="IKVM.OpenJDK.Core" version="7.2.4630.5" targetFramework="net452" />
<package id="IKVM.OpenJDK.Misc" version="7.2.4630.5" targetFramework="net452" />
<package id="IKVM.OpenJDK.Naming" version="7.2.4630.5" targetFramework="net452" />
<package id="IKVM.OpenJDK.Remoting" version="7.2.4630.5" targetFramework="net452" />
<package id="IKVM.OpenJDK.Security" version="7.2.4630.5" targetFramework="net452" />
<package id="IKVM.OpenJDK.SwingAWT" version="7.2.4630.5" targetFramework="net452" />
<package id="IKVM.OpenJDK.Text" version="7.2.4630.5" targetFramework="net452" />
<package id="IKVM.OpenJDK.Util" version="7.2.4630.5" targetFramework="net452" />
<package id="IKVM.OpenJDK.XML.API" version="7.2.4630.5" targetFramework="net452" />
<package id="IKVM.Runtime" version="7.2.4630.5" targetFramework="net452" />
</packages>