Skip to content

Compressing rolled files #234

Open
Open
@lraulea

Description

@lraulea

I'm really struggling to find a way to zip the rolled old fromFile, at the moment that log4net decides to rollover on date. I don't see any direct way to get notified if a log file was rolled, only indirectly and incomplete.

My kind request is to implement ALT-3, if possible.

ALT-1: override RollOverRenameFiles() method

protected override void RollOverRenameFiles(string baseFileName)
{
    base.RollOverRenameFiles(baseFileName);
    //do zip
}

Result= NOK
-only works for rollover based on size
-for rollover based on date, this method is not called, no zip

ALT-2: override AdjustFileBeforeAppend() method

protected override void AdjustFileBeforeAppend()
{
   var currentFile = File;
   base.AdjustFileBeforeAppend();
   if (!currentFile.Equals(File))
   {
      //do zip
   }
}

Result= NOK
-works for rollover based on size on same day
-when crossing a date boundary, currentFile differs from File => zip OK
-when starting the main app the next day, it misses the previous day file => no zip

ALT-3: override RollFile(string fromFile, string toFile) method

protected override void RollFile(string fromFile, string toFile)
{
   base.RollFile(string fromFile, string toFile);
   //do zip on 'fromFile'
}

Cannot override now because method is not virtual

So, my request is: could this RollFile() be made virtual?

Thanks!

Greetings,
Liviu

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions