我正在以编程方式在 log4net 中配置 RollingFileAppender。我目前有这样的事情:
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
这拒绝根据日期滚动日志。如果我将 RollingStyle 切换为 Size 或 Composite,它将滚动,但仅基于大小,而不是基于日期。我尝试删除 StaticLogFileName 并使用 DatePattern 无济于事。
我必须以编程方式配置它,因为我不知道运行时附加器的数量,所以使用 XML 配置它,我过去已经能够使用它,这是不行的。有人有什么想法吗?我错过了什么吗?