0

I am using C# 4.6.1.

Let's assume I have successfully configured a log4net.Appender.RollingFileAppender, which will roll to a new trace file after a certain time or when the trace reaches a certain size threshold.

What I want to do now is to detect every time there is a file roll, because I need to do a certain operation with the full trace file that was just rolled, which is out of the scope of the question (I basically need to zip it, copy it to a certain folder and raise an event).

Is there a way to configure log4net to raise an event or execute a specific method when it is rolling to a new trace file?

Silverman
  • 299
  • 1
  • 10

1 Answers1

0

The log4net framework does not have out-of-the-box support for that or any configuration you can tweak to get it.

You need to implement your own custom appender class that inherits from RollingFileAppender and override its methods to suite your needs. The methods that more likely be of your interest are Append, DoAppend, RollFile and the RollOver... methods.

For more info check the reference.

Javier Silva Ortíz
  • 2,864
  • 1
  • 12
  • 21