Serilog

Project Hosting
NuGet Package NServiceBus.Serilog (3.x) | License
This is a community run project. License and support are independent of Particular Software.
Target NServiceBus Version: 6.x

Support for writing all NServiceBus log entries to Serilog.

Usage

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

LogManager.Use<SerilogFactory>();

Seq

To log to Seq:

Log.Logger = new LoggerConfiguration()
    .WriteTo.Seq("http://localhost:5341")
    .MinimumLevel.Information()
    .CreateLogger();

LogManager.Use<SerilogFactory>();

Filtering

NServiceBus can write a significant amount of information to the log. To limit this information use the filtering features of the underlying logging framework.

For example to limit log output to a specific namespace.

Here is a code configuration example for adding a Filter.

Log.Logger = new LoggerConfiguration()
    .WriteTo.ColoredConsole(
        restrictedToMinimumLevel: LogEventLevel.Debug
    )
    .Filter.ByIncludingOnly(
        inclusionPredicate: Matching.FromSource("MyNamespace"))
    .CreateLogger();

LogManager.Use<SerilogFactory>();

Samples

Related Articles

  • Logging
    Manage and integrate with NServiceBus logging.

Last modified