Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/manigandham/serilog-sinks-fastconsole
Serilog sink that writes to console with high-performance non-blocking output.
https://github.com/manigandham/serilog-sinks-fastconsole
logging manigandham serilog serilog-sink
Last synced: about 2 months ago
JSON representation
Serilog sink that writes to console with high-performance non-blocking output.
- Host: GitHub
- URL: https://github.com/manigandham/serilog-sinks-fastconsole
- Owner: manigandham
- License: mit
- Created: 2019-07-17T03:55:24.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-10-19T09:54:06.000Z (over 1 year ago)
- Last Synced: 2024-11-05T11:09:45.293Z (3 months ago)
- Topics: logging, manigandham, serilog, serilog-sink
- Language: C#
- Homepage:
- Size: 113 KB
- Stars: 19
- Watchers: 4
- Forks: 9
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Serilog.Sinks.FastConsole
Serilog sink that writes to console with high-performance non-blocking output. Supports plaintext and JSON output but **does not support themes and colors**.
This sink uses a [background channel](https://ndportmann.com/system-threading-channels/) with a single reader, efficient text buffer, and asynchronous writes to remove all blocking and lock contention to the console output stream. It also implements `IDiposable` so calling `Log.CloseAndFlush()` will ensure all lines are flushed.
Recommended for high-volume logging where console output is collected or redirected to another system, for example this library was originally created for large application clusters running in Kubernetes and logging hundreds of JSON objects every second.
- Built for `net6.0`, `netstandard2.1`, `netstandard2.0`
- Release notes here: [CHANGELOG.md](CHANGELOG.md)## Getting started
#### Install [package from Nuget](https://www.nuget.org/packages/Serilog.Sinks.FastConsole/):
```
dotnet add package Serilog.Sinks.FastConsole
```#### Configure Logger (using code):
```csharp
var config = new FastConsoleSinkOptions { UseJson = true };
Log.Logger = new LoggerConfiguration().WriteTo.FastConsole(config).CreateLogger();
```- Serilog example for .NET 6: https://blog.datalust.co/using-serilog-in-net-6/
## Sink Options
| Name | Default | Description |
| --------------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `UseJson` | true | Enable to write log events as a JSON object with `{ timestamp, level, message, properties }` structure. Provide an `ITextFormatter` implementation instead to customize the output completely. |
| `QueueLimit` | null | Set max limit for the number of log entries queued in memory. Used to provide backpressure and avoid out-of-memory issues for high-volume logging. |
| `BlockWhenFull` | false | Set behavior when queue is full. When `true` this will block the thread until logs are output to console. Only applicable if `QueueLimit` is set. |