tags:

views:

9

answers:

1

I'm configuring log4net with:

[assembly: log4net.Config.XmlConfigurator(ConfigFile = "../ProjectName/Log4Net.config", Watch = true)]

I have 2 appenders configured: 1. An AdoNetAppender logging to a Log table on a mssql2008 database. 2. A FileAppender that just looks like this:

<appender name="FileAppender" type="log4net.Appender.FileAppender">
  <file value="c:\log-file.txt" />
  <appendToFile value="true" />
  <lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
  <layout type="log4net.Layout.PatternLayout">
    <conversionPattern value="%date [%thread] %-5level %logger - %message%newline" />
  </layout>
</appender>

The problem is that when an action gets logged, it immediately appears in log-file.txt. It doesn't appear as an entry in the database until I either do iisreset, recompile the web code, or recycle the app pool.

The configuration seems right as the action does eventually get logged to the database. I just don't understand why the delay.

Can anybody give me a reason or tell me how to fix it?