Skip to content

Commit 3312716

Browse files
committed
Document Blocking support, minor doc tweaks
1 parent 870c52e commit 3312716

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

README.md

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ Install from [NuGet](https://nuget.org/packages/serilog.sinks.async):
1212
Install-Package Serilog.Sinks.Async
1313
```
1414

15-
Assuming you have already installed the target sink, such as the rolling file sink, move the wrapped sink's configuration within a `WriteTo.Async()` statement:
15+
Assuming you have already installed the target sink, such as the file sink, move the wrapped sink's configuration within a `WriteTo.Async()` statement:
1616

1717
```csharp
1818
Log.Logger = new LoggerConfiguration()
19-
.WriteTo.Async(a => a.RollingFile("logs/myapp-{Date}.txt"))
19+
.WriteTo.Async(a => a.File("logs/myapp.log"))
2020
// Other logger configuration
2121
.CreateLogger()
2222

@@ -26,7 +26,7 @@ Log.Information("This will be written to disk on the worker thread");
2626
Log.CloseAndFlush();
2727
```
2828

29-
The wrapped sink (`RollingFile` in this case) will be invoked on a worker thread while your application's thread gets on with more important stuff.
29+
The wrapped sink (`File` in this case) will be invoked on a worker thread while your application's thread gets on with more important stuff.
3030

3131
Because the memory buffer may contain events that have not yet been written to the target sink, it is important to call `Log.CloseAndFlush()` or `Logger.Dispose()` when the application exits.
3232

@@ -36,7 +36,19 @@ The default memory buffer feeding the worker thread is capped to 10,000 items, a
3636

3737
```csharp
3838
// Reduce the buffer to 500 events
39-
.WriteTo.Async(a => a.RollingFile("logs/myapp-{Date}.txt"), 500)
39+
.WriteTo.Async(a => a.File("logs/myapp.log"), bufferSize: 500)
40+
```
41+
42+
### Blocking
43+
44+
Warning: For the same reason one typically does not want exceptions from logging to leak into the execution path, one typically does not want a logger to be able to have the side-efect of actually interrupting application processing until the log propagation has been unblocked.
45+
46+
When the buffer size limit is reached, the default behavior is to drop any further attempted writes until the queue abates, reporting each such failure to the `Serilog.Debugging.SelfLog`. To replace this with a blocking behaviour, set `blockWhenFull` to `true`.
47+
48+
```csharp
49+
// Wait for any queued event to be accepted by the `File` log before allowing the calling thread
50+
// to resume its application work after a logging call when there are 10,000 LogEvents waiting
51+
.WriteTo.Async(a => a.File("logs/myapp.log"), blockWhenFull: true)
4052
```
4153

4254
### XML `<appSettings>` and JSON configuration
@@ -50,7 +62,7 @@ Using [Serilog.Settings.Configuration](https://github.com/serilog/serilog-settin
5062
"Name": "Async",
5163
"Args": {
5264
"configure": [{
53-
"Name": "LiterateConsole"
65+
"Name": "Console"
5466
}]
5567
}
5668
}]

0 commit comments

Comments
 (0)