Home > Mobile >  Log4Net on multiple nodes behind loadbalancer overwrite previous day rolling files
Log4Net on multiple nodes behind loadbalancer overwrite previous day rolling files

Time:09-06

We are using the RollingFileAppender in a web-applicfation running behind a load-balaner on multiple nodes. We noticed that logs of previous days often are very small, only a few lines, while the current log is large. It is not 100% consistent, about 1 in 5 previous logs apear to be a full log (using 2 nodes).

We figured that both nodes must be renaming log.log to the previous date with a minimal timespan between them. The last node to do so will actually overwrite the previous log with the new logfile created moments earlier by the first node.

This is our curated config:

<log4net>
  <appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">
    <lockingModel type="log4net.Appender.FileAppender MinimalLock"/>
    <file value="\\shared-path\log.log" />
    <datePattern value="yyyy-MM-dd.'txt'"/>
    <staticLogFileName value="true"/>
    <appendToFile value="true"/>
    <rollingStyle value="Date"/>
    <maxSizeRollBackups value="10"/>
    <maximumFileSize value="20MB"/>
    <layout type="log4net.Layout.PatternLayout">
      <conversionPattern value="           
  • Related