@@ -30,7 +30,7 @@ internal partial class FileLoggerProcessor : IAsyncDisposable
30
30
private bool _maxFilesReached ;
31
31
private TimeSpan _flushInterval ;
32
32
private W3CLoggingFields _fields ;
33
- private DateTime _today = DateTime . Now ;
33
+ private DateTime _today ;
34
34
private bool _firstFile = true ;
35
35
36
36
private readonly IOptionsMonitor < W3CLoggerOptions > _options ;
@@ -40,6 +40,9 @@ internal partial class FileLoggerProcessor : IAsyncDisposable
40
40
private readonly Task _outputTask ;
41
41
private readonly CancellationTokenSource _cancellationTokenSource ;
42
42
43
+ // Internal to allow for testing
44
+ internal ISystemDateTime SystemDateTime { get ; set ; } = new SystemDateTime ( ) ;
45
+
43
46
private readonly object _pathLock = new object ( ) ;
44
47
45
48
public FileLoggerProcessor ( IOptionsMonitor < W3CLoggerOptions > options , IHostEnvironment environment , ILoggerFactory factory )
@@ -98,6 +101,8 @@ public FileLoggerProcessor(IOptionsMonitor<W3CLoggerOptions> options, IHostEnvir
98
101
}
99
102
} ) ;
100
103
104
+ _today = SystemDateTime . Now ;
105
+
101
106
// Start message queue processor
102
107
_cancellationTokenSource = new CancellationTokenSource ( ) ;
103
108
_outputTask = Task . Run ( ProcessLogQueue ) ;
@@ -155,7 +160,7 @@ private async Task ProcessLogQueue()
155
160
private async Task WriteMessagesAsync ( List < string > messages , CancellationToken cancellationToken )
156
161
{
157
162
// Files are written up to _maxFileSize before rolling to a new file
158
- DateTime today = DateTime . Now ;
163
+ DateTime today = SystemDateTime . Now ;
159
164
160
165
if ( ! TryCreateDirectory ( ) )
161
166
{
0 commit comments