https://github.com/rebus-org/rebus.serilog
:bus: Serilog logging integration for Rebus
https://github.com/rebus-org/rebus.serilog
rebus serilog
Last synced: 28 days ago
JSON representation
:bus: Serilog logging integration for Rebus
- Host: GitHub
- URL: https://github.com/rebus-org/rebus.serilog
- Owner: rebus-org
- License: other
- Created: 2016-08-31T09:45:28.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2023-11-15T12:23:56.000Z (over 1 year ago)
- Last Synced: 2025-04-02T20:11:44.099Z (about 2 months ago)
- Topics: rebus, serilog
- Language: C#
- Homepage: https://mookid.dk/category/rebus
- Size: 4.93 MB
- Stars: 9
- Watchers: 4
- Forks: 6
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Rebus.Serilog
[](https://www.nuget.org/packages/Rebus.Serilog)
Provides a Serilog logging integration for [Rebus](https://github.com/rebus-org/Rebus).

---
Do it like this if you just want Rebus to use your global Serilog logger directly:
```csharp
Configure.With(...)
.Logging(l => l.Serilog())
.Transport(t => t.Use(...))
.(...)
.Start();
```or like this if you want to customize it:
```csharp
var logger = Log.ForContext("queue", queueName);Configure.With(...)
.Logging(l => l.Serilog(logger))
.Transport(t => t.Use(..., queueName))
.(...)
.Start();
```Initialize your Serilog logging with Rebus' correlation ID enricher if you'd like the correlation ID of handled messages to be added automatically to all log output generated from message handlers:
```csharp
Log.Logger = new LoggerConfiguration()
.WriteTo.(...)
.Enrich.WithRebusCorrelationId("CorrelationId")
.CreateLogger();
```and then either use real structured logging (e.g. to an aggregator like Elastic), or remember to include it in your output template (here shown with `ColoredConsole`):
```csharp
// 👇
Log.Logger = new LoggerConfiguration()
.WriteTo.ColoredConsole(outputTemplate: "{Timestamp:HH:mm:ss} {Level:u3} ({CorrelationId}) {Message}{NewLine}{Exception}")
.(...)
```