How to track down log4net problems

First you have to set this value on the application configuration file:

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

Then, to determine the file in which you want to save the output you can add the following code in the same .config file:

<configuration>
...

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

...
</configuration>

You can find a more detailed explanation under
‘How do I enable log4net internal debugging?’
in the log4net FAQ page.

Leave a Comment