Custom Serilog configuration

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

This sample illustrates how to customize logging by configuring Serilog targets and rules.

Configure Serilog

Log.Logger = new LoggerConfiguration()
    .WriteTo.Console()
    .CreateLogger();

Pass the configuration to NServiceBus

LogManager.Use<SerilogFactory>();

var endpointConfiguration = new EndpointConfiguration("Samples.Logging.SerilogCustom");

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