Serilog Seq Logging

Component: Serilog Logger
NuGet Package NServiceBus.Serilog (6.x)
This is a community maintained project
Target NServiceBus Version: 7.x

Introduction

Illustrates customizing Serilog usage to log to Seq.

Prerequisites

An instance of Seq running one http://localhost:5341.

Code walk-through

Configure Serilog

var tracingLog = new LoggerConfiguration()
    .WriteTo.Seq("http://localhost:5341")
    .MinimumLevel.Information()
    .CreateLogger();
var serilogFactory = LogManager.Use<SerilogFactory>();
serilogFactory.WithLogger(tracingLog);

Pass that configuration to NServiceBus

var endpointConfiguration = new EndpointConfiguration("Samples.Logging.SerilogTracing");
var serilogTracing = endpointConfiguration.EnableSerilogTracing(tracingLog);
serilogTracing.EnableSagaTracing();
serilogTracing.EnableMessageTracing();

Ensure logging is flushed on shutdown

await endpointInstance.Stop()
    .ConfigureAwait(false);
Log.CloseAndFlush();

Related Articles

  • Logging
    Manage and integrate with NServiceBus logging.
  • Serilog
    Logging to Serilog.

Last modified