I need to catch log4net exceptions (its own exceptions not app exceptions logged by it). I wish there's a way of doing it this way:
Try
_logger.Info(response)
Catch ex As Exception
Excepciones.HandleException(ex, "PolicyCore")
End Try
I have this code implemented and there's no errors in compilation but i force log4net to have an error (pointing to a non existing database in the config file) and nothing is threw.
I've tried the listener aproach:
<appSettings>
<add key="log4net.Internal.Debug" value="true" />
</appSettings>
<system.diagnostics>
<trace autoflush="true" indentsize="4" >
<listeners>
<add name="textWriterTraceListener"
type="System.Diagnostics.TextWriterTraceListener"
initializeData="C:\\temp\\log4net.txt" />
<remove name="Default" />
</listeners>
</trace>
</system.diagnostics>
and it's writing the errors to log4net.txt, the forced ones i mean.
This last aproach has a couple of drawbacks: it won't append every error to the file, if the error is the same it doesn't write it, i can't get the listener to write every error to that file, only one (I don't know how to fully configure the trace listener, it might be that). Thus it won't append the date and hour to every line wich is a necesity for me. Finally i can't give structure to it (xml).
Even if the listener work i need to use the try/catch aproach, since i'm using ExceptionHandling from Enterprise library to log the errors in my app.
Anyone who has faced the problem and/or has a solution?