@@ -30,7 +30,7 @@ internal partial class FileLoggerProcessor : IAsyncDisposable
3030 private bool _maxFilesReached ;
3131 private TimeSpan _flushInterval ;
3232 private W3CLoggingFields _fields ;
33- private DateTime _today = DateTime . Now ;
33+ private DateTime _today ;
3434 private bool _firstFile = true ;
3535
3636 private readonly IOptionsMonitor < W3CLoggerOptions > _options ;
@@ -40,6 +40,9 @@ internal partial class FileLoggerProcessor : IAsyncDisposable
4040 private readonly Task _outputTask ;
4141 private readonly CancellationTokenSource _cancellationTokenSource ;
4242
43+ // Internal to allow for testing
44+ internal ISystemDateTime SystemDateTime { get ; set ; } = new SystemDateTime ( ) ;
45+
4346 private readonly object _pathLock = new object ( ) ;
4447
4548 public FileLoggerProcessor ( IOptionsMonitor < W3CLoggerOptions > options , IHostEnvironment environment , ILoggerFactory factory )
@@ -98,6 +101,8 @@ public FileLoggerProcessor(IOptionsMonitor<W3CLoggerOptions> options, IHostEnvir
98101 }
99102 } ) ;
100103
104+ _today = SystemDateTime . Now ;
105+
101106 // Start message queue processor
102107 _cancellationTokenSource = new CancellationTokenSource ( ) ;
103108 _outputTask = Task . Run ( ProcessLogQueue ) ;
@@ -155,7 +160,7 @@ private async Task ProcessLogQueue()
155160 private async Task WriteMessagesAsync ( List < string > messages , CancellationToken cancellationToken )
156161 {
157162 // Files are written up to _maxFileSize before rolling to a new file
158- DateTime today = DateTime . Now ;
163+ DateTime today = SystemDateTime . Now ;
159164 var fullName = GetFullName ( today ) ;
160165 // Don't write to an incomplete file left around by a previous FileLoggerProcessor
161166 if ( _firstFile )
0 commit comments