Log4net randomly stops logging.

Log4Net will fail silently if something goes wrong and it is unable to write to its appenders. This is actually a good thing, since it means a bit of failed logging won’t bring down an otherwise healthy system, but it can be annoying when something isn’t logging as you expect.

Your best bet is to turn on log4net’s own internal logging to do some diagnostics and (hopefully) work out why it’s failing.

So in your app’s config file add:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <appSettings>
        <add key="log4net.Internal.Debug" value="true"/>
    </appSettings>
</configuration>

which will turn on the internal logging, which gets sent to System.Diagnostics.Trace, so you can add:

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

to capture this to a file.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)