tags:

views:

349

answers:

2

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.

+3  A: 

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:

<appSettings>
    <add key="log4net.Internal.Debug" value="true"/>
</appSettings>

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

Andy White
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
+1  A: 

Expanding on the previous answer -

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

  <system.diagnostics>
    <trace autoflush="true">
      <listeners>
        <add
            name="textWriterTraceListener"
            type="System.Diagnostics.TextWriterTraceListener"
            initializeData="c:\temp\log4net.txt" />
      </listeners>
    </trace>
  </system.diagnostics>

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.

glaxaco