How to specify date interval?
-
26-02-2021 - |
Pregunta
I want to use RollingMode.Date to log by date. But default interval is one minute. I looked into source and saw, that class has protected enum RollPoint
/// <summary>
/// The code assumes that the following 'time' constants are in a increasing sequence.
/// </summary>
/// <remarks>
/// <para>
/// The code assumes that the following 'time' constants are in a increasing sequence.
/// </para>
/// </remarks>
protected enum RollPoint
{
InvalidRollPoint = -1,
TopOfMinute,
TopOfHour,
HalfDay,
TopOfDay,
TopOfWeek,
TopOfMonth
}
How to specify RollPoint to RollingFileAppender object?
Thanks!
Solución
You can use datePattern
property of log configuration.
To change the rolling period adjust the DatePattern value. For example, a date pattern of "yyyyMMdd" will roll every day. See System.Globalization.DateTimeFormatInfo for a list of available patterns.
It narrows down to adding
<datePattern value="yyyyMMdd-HHmm" />
to your appender configuration. More information here.
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow