Take the 2-minute tour ×

It seems that Log4Net silently shuts down for reasons that are not obvious, and I'm at a loss how to troubleshoot it. My hunch is that a particular appender is failing on a specific log message and that seems to shut down the whole stack.

Is there a way to get Log4Net to throw an exeception (at least during our debug phase) rather than a slient shutting down of the service.

share|improve this question
add comment

2 Answers

up vote 9 down vote accepted

I think there's a config value you can put in the appSettings section of your app.config/web.config to turn on internal debug statements in log4net:


This will give you some insight into any errors that log4net might be swallowing.

share|improve this answer
After a little more digging (following your pointer to enable internal debugging it looks like enabling a listener for the System.Diagnostics.Trace is also required. –  Ralph Shillington Mar 25 '09 at 20:01
It should also be noted that appSettings needs to go before system.diagnostics attribute. –  Dan May 10 '11 at 16:43
add comment

Expanding on the previous answer -

To add a trace listener for the log4net.Internal.Debug trace, add this to your app config:

    <trace autoflush="true">
            initializeData="c:\temp\log4net.txt" />

Replace the initializeData attribute value above with your desired log file path. Be sure the application or ASP.NET server process has permission to write to this file.

Another thing you can do is inspect the messages that are returned from the log4net configuration on startup. As of log4net version 1.2.11, the XmlConfigurator.Configure() methods return an ICollection containing strings listing problems encountered during the the configuration process.

So if you've got something like this:


change it to

ICollection configMessages = XmlConfigurator.Configure();

and inspect configMessages in a debugger, or print them out somewhere, e.g.

foreach (string msg in configMessages)

If all else fails, download the log4net source, add the project to your solution, and reference the project instead of log4net.dll. Now you can step into the log4net calls in the debugger.

share|improve this answer
add comment

Your Answer


