Fedepr
Fedepr

Reputation: 1

avoid log4net splitting logs across midnight

looked into similar log4net rolling file apender across midnight but it's not the same. i have a log4net configuration which is the following

<appender name="LogFileAppender" type="log4net.Appender.RollingFileAppender">
  <file type="log4net.Util.PatternString" value="XXX\MYPROGRAM_%property{id}_" />
  <appendToFile value="true" />
  <rollingStyle value="Size" />
  <maxSizeRollBackups value="5" />
  <maximumFileSize value="10MB" />
  <staticLogFileName value="true" />
  <rollingStyle value="Composite" />
  <datePattern value="yyyyMMdd'.txt'" />
  <param name="StaticLogFileName" value="false" />
  <layout type="log4net.Layout.PatternLayout">
    <conversionPattern value="%d [%t] %-5p %c %m%n" />
  </layout>
</appender>

where "%property{id}" is some elaboration DETAIL of the MYPROGRAM instance, resulting in file logs like "MYPROGRAM_DETAIL_YYYYMMDD.TXT" (and eventually .1---.N suffixes if files are too big). i discovered that across midnight the file log is being closed (and written until that) and it opens a new one with the date of the new day, continuing to log in the new file.

what I want is that the file that is being written before midnight, remains opened and written with the same name, until the end of the elaboration, without splitting the log in 2 files. PS: I think I have to maintain the because of the dynamically created file name due to %property{id}

the official documentation seems not very clear about this. any ideas?

Upvotes: 0

Views: 27

Answers (0)

Related Questions