Setting up RollingFileAppender

I am working on setting up RollingFileAppender in log4net programmatically. I currently have something like this:

RollingFileAppender fa = new RollingFileAppender();
fa.AppendToFile = true;
fa.RollingStyle = RollingFileAppender.RollingMode.Date;
fa.DatePattern = "yyyyMMdd";
fa.StaticLogFileName = true;
// Set more properties and add the appender to the root repository

This refuses to collapse the journal depending on the date. If I switch the RollingStyle to Size or Composite, it will be collapsed, but only the size is based, not based on the date. I tried removing StaticLogFileName and playing with DatePattern to no avail.

I need to configure this programmatically since I don’t know the number of additions at runtime, so setting it up with XML, which I was able to get in the past, is not-go. Does anyone have any idea? Am I missing something?

+3
source share
2 answers

, RollingFileAppender ( , ) IOptionHandler, " , , . , , .

: " ActivateOptions , . ActivateOptions undefined ."

xml , log4net.

+2

ActivateOptions() appender, appender , , , . , .

0

Source: https://habr.com/ru/post/1704216/


All Articles