Skip to content

Commit 752c27f

Browse files
authored
Merge pull request #17 from serilog/dev
1.1.0 Release
2 parents bb2896e + a0c1aa7 commit 752c27f

File tree

3 files changed

+10
-19
lines changed

3 files changed

+10
-19
lines changed

README.md

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Serilog.Sinks.Async [![Build status](https://ci.appveyor.com/api/projects/status/gvk0wl7aows14spn?svg=true)](https://ci.appveyor.com/project/serilog/serilog-sinks-async) [![NuGet](https://img.shields.io/nuget/vpre/Serilog.Sinks.Async.svg?maxAge=2592000)](https://www.nuget.org/packages/Serilog.Sinks.Async) [![Join the chat at https://gitter.im/serilog/serilog](https://img.shields.io/gitter/room/serilog/serilog.svg)](https://gitter.im/serilog/serilog)
1+
# Serilog.Sinks.Async [![Build status](https://ci.appveyor.com/api/projects/status/gvk0wl7aows14spn?svg=true)](https://ci.appveyor.com/project/serilog/serilog-sinks-async) [![NuGet](https://img.shields.io/nuget/v/Serilog.Sinks.Async.svg)](https://www.nuget.org/packages/Serilog.Sinks.Async) [![Join the chat at https://gitter.im/serilog/serilog](https://img.shields.io/gitter/room/serilog/serilog.svg)](https://gitter.im/serilog/serilog)
22

33
An asynchronous wrapper for other [Serilog](https://serilog.net) sinks. Use this sink to reduce the overhead of logging calls by delegating work to a background thread. This is especially suited to non-batching sinks like the [File](https://github.com/serilog/serilog-sinks-file) and [RollingFile](https://github.com/serilog-serilog-sinks-rollingfile) sinks that may be affected by I/O bottlenecks.
44

@@ -9,7 +9,7 @@ An asynchronous wrapper for other [Serilog](https://serilog.net) sinks. Use this
99
Install from [NuGet](https://nuget.org/packages/serilog.sinks.async):
1010

1111
```powershell
12-
Install-Package Serilog.Sinks.Async -Pre
12+
Install-Package Serilog.Sinks.Async
1313
```
1414

1515
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:
@@ -32,8 +32,6 @@ Because the memory buffer may contain events that have not yet been written to t
3232

3333
### Buffering
3434

35-
This sink uses a separate worker thread to write to your sink, freeing up the calling thread to run in your app without having to wait.
36-
3735
The default memory buffer feeding the worker thread is capped to 10,000 items, after which arriving events will be dropped. To increase or decrease this limit, specify it when configuring the async sink.
3836

3937
```csharp

src/Serilog.Sinks.Async/Sinks/Async/BackgroundWorkerSink.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using Serilog.Core;
55
using Serilog.Debugging;
66
using Serilog.Events;
7+
using System.Threading.Tasks;
78

89
namespace Serilog.Sinks.Async
910
{
@@ -14,7 +15,7 @@ sealed class BackgroundWorkerSink : ILogEventSink, IDisposable
1415
volatile bool _disposed;
1516
readonly CancellationTokenSource _cancel = new CancellationTokenSource();
1617
readonly BlockingCollection<LogEvent> _queue;
17-
readonly Thread _worker;
18+
readonly Task _worker;
1819

1920
public BackgroundWorkerSink(Logger pipeline, int bufferCapacity)
2021
{
@@ -23,8 +24,7 @@ public BackgroundWorkerSink(Logger pipeline, int bufferCapacity)
2324
_pipeline = pipeline;
2425
_bufferCapacity = bufferCapacity;
2526
_queue = new BlockingCollection<LogEvent>(_bufferCapacity);
26-
_worker = new Thread(Pump) { IsBackground = true, Name = typeof(BackgroundWorkerSink).FullName };
27-
_worker.Start();
27+
_worker = Task.Factory.StartNew(Pump, CancellationToken.None, TaskCreationOptions.LongRunning | TaskCreationOptions.DenyChildAttach, TaskScheduler.Default);
2828
}
2929

3030
public void Emit(LogEvent logEvent)
@@ -39,7 +39,7 @@ public void Dispose()
3939
{
4040
_disposed = true;
4141
_cancel.Cancel();
42-
_worker.Join();
42+
_worker.Wait();
4343
_pipeline.Dispose();
4444
// _cancel not disposed, because it will make _cancel.Cancel() non-idempotent
4545
}

src/Serilog.Sinks.Async/project.json

+4-11
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
{
2-
"version": "1.0.1-*",
1+
{
2+
"version": "1.1.0-*",
33

44
"description": "Asynchronous sink wrapper for Serilog.",
55
"authors": [ "Jezz Santos", "Serilog Contributors" ],
@@ -24,16 +24,9 @@
2424
"frameworks": {
2525
"net4.5": {
2626
},
27-
"netstandard1.3": {
27+
"netstandard1.1": {
2828
"dependencies": {
29-
"Microsoft.CSharp": "4.0.1",
30-
"System.Collections": "4.0.11",
31-
"System.Linq": "4.1.0",
32-
"System.Runtime": "4.1.0",
33-
"System.Runtime.Extensions": "4.1.0",
34-
"System.Threading": "4.0.11",
35-
"System.Collections.Concurrent": "4.0.12",
36-
"System.Threading.Thread": "4.0.0"
29+
"System.Collections.Concurrent": "4.0.12"
3730
}
3831
}
3932
}

0 commit comments

Comments
 (0)