2

I have today discovered that our production systems are missing a lot from their log files. Our current log file contains everything (from midnight to midnight) however when I look at the previous day logs it stops at around 1AM.

I have gone over logs that were created in last few months and it's very random when logs are being cut. Mostly it is between 2400 and 0300.

<appender name="fileLogAppender" type="log4net.Appender.RollingFileAppender" >
    <file name="filename" value="..\Logs\Errors.xml" />
    <encoding value="utf-8" />
    <appendToFile value="true" />
    <rollingStyle value="Date" />
    <datePattern value="yyyyMMdd"/>
    <threshold value="ERROR" />
    <lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
    <layout type="log4net.Layout.XmlLayoutSchemaLog4j">
      <locationInfo value="true"/>
    </layout>
  </appender>
<root>
    <level value="Debug" />
    <appender-ref ref="fileLogAppender" />
  </root>

This spits out XML file with errors (I use YALV! for reading our logs). Our version of Log4net is 1.2.10 (we are unable to upgrade it as its comes with a third party software that seem to crash if log4net is changed.

EDIT1:

I'm running a CMS site (EPiServer 6 R2) - .NET4 in IIS7 load balanced (4 servers + 1DB). Yesterday's log of 50MB got rolled over to a log of 4KB.

Luke
  • 1,802
  • 20
  • 31
  • Can you explain a little more about your systems? If it is an IIS app it might be that it is going dormant due to lack of use. – Eric Scherrer Jan 23 '14 at 19:04
  • Added more info @EricScherrer – Luke Jan 23 '14 at 22:01
  • When you say rolled over, you mean when it cut off yesterdays log and started a new file it was only 4KB when you checked it last? – Eric Scherrer Jan 24 '14 at 01:12
  • @EricScherrer What I mean is that before I went to bed our current Errors.xml was up to 50MB and when rollover happened at midnight somehow file for 23-01-14 now has only 4KB. I would have expected that file to be a bit more than 50MB since thats where it was at. – Luke Jan 24 '14 at 03:39
  • Ok I'm just shooting from the hip here. I think you need to include the date in the log file name, otherwise it is just going to keep getting overridden. Here is an example: – Eric Scherrer Jan 24 '14 at 14:20

1 Answers1

0

I had the same problem, the rolling file only saved log rows from midnight til a daily recycling of the appPool at 2 AM, and all the rows from the day before were gone. The problem could for example be caused by having several sites in your solution,where the different sites lock the log file. This solved my problem, and also gives the possibility to log to the same log file from all of your load balanced servers, which could be really helpful!

http://log4netremotelogging.codeplex.com/

Ulrika
  • 1