Log4Net not writing to the database

  1. Check if log4net.dll is placed in the same folder as your application.
  2. Try to enable log4net self-logging, maybe it'll help to find out:

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

See also the official log4net FAQ.


Right, after hours of pulling my hair out - I've cracked it.

This line:

log4net.Config.XmlConfigurator.Configure();

Needed putting in prior to any logging (well, as early as possible in the app). That's it. That was all it took. This is one of those problems were I'm extremely relieved but frustrated at the same time.


I would recommend turning on Log4Net debugging:

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

That may point you in the right direction if there's an error that's occurring behind the scenes. The output will be directed to the console output in the IDE or in the command line.