You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+42-41Lines changed: 42 additions & 41 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -37,6 +37,8 @@ Below is a sample configuration for the file provider. The values shown are the
37
37
"MaxFileSizeInMB": 50, // this can be decimal
38
38
"FormatterName": "simple", // simple or json
39
39
"Append": true,
40
+
"FlushToDisk" : false, // true to indicate that flush operations should flush all the way to disk (ie fsync)
41
+
"MaxFlushInterval" : null, // max ms for which to allow before a flush operation on log writes
40
42
"formatterOptions" : {
41
43
// see formatter options below
42
44
}
@@ -140,72 +142,71 @@ Example configuration
140
142
Log files can have a max file size at which time a new file will be create with a incremented id appended. You may also specify a maximum number of files to retain. Once the maximum number of files has been reached, the oldest will be overwritten.
141
143
Using RollInterval setting, you can also specify that a date will be appended to the file name and the files will roll according to the date in 'yyyyMMddHH' format.
142
144
143
-
## Custom Formatters
145
+
## Custom Formatters
144
146
145
147
To implment a custom formatter, create a class that derives from ```FileFormatter<TOptions>```. Then register the formatter using a name and specify that name on the Logger options
146
148
147
-
## Benchmarks
149
+
## Flush behavior
150
+
151
+
For performance reasons, this library uses a message queue and a dedicated thread for writing log messages to the file. By default, a flush() is called when the write thread empties the queue of log messages. In situations where there is a high throughput of log messages, file buffers may not flush for quite some time as the queue is not cleared. You can optionally specify a maximum amount of time in (MaxFlushInterval) ms to go without a file flush operation. A value of 0 would force a flush on every messsage write. Note that even a flush() operation may not actually ensure that the data is written to the physical disk. By default, the flush ensures that the data is written to the drive cache. If you wish to ensure that a flush will ensure the data is written to disk set "FlushToDisk" to true. This could have some minor performance implications.
148
152
149
-
The library has be benchmarked against a couple of other popular file loggers for .NET core. Specically NReco and Karambolo loggers. See the results below.
153
+
## Benchmarks
150
154
151
-
#### Simple Text Message
152
-
```
155
+
The library has been benchmarked against a couple of other popular file loggers for .NET core. Specically NReco and Karambolo loggers. See the results below.
153
156
154
-
BenchmarkDotNet v0.13.12, Windows 11 (10.0.22631.3007/23H2/2023Update/SunValley3)
157
+
### Simple Text Message
158
+
```
159
+
BenchmarkDotNet v0.14.0, Windows 11 (10.0.26100.2605)
155
160
AMD Ryzen 5 5600H with Radeon Graphics, 1 CPU, 12 logical and 6 physical cores
| Bleess_multifile_single_write | 1.249 us | 0.0267 us | 0.0286 us | 0.1602 | - | 1.36 KB |
209
+
| Karambolo_multifile_single_write | 1.281 us | 0.1082 us | 0.1246 us | 0.1602 | 0.0153 | 1.31 KB |
209
210
210
211
## Credits
211
212
- Some of the code was a adapted from dotnet source code (specifically Microsoft.Extensions.Logging.Console) https://github.com/dotnet/runtime/tree/master/src/libraries/Microsoft.Extensions.Logging.Console
0 commit comments