NuGet Package: NServiceBus.Extensions.Logging (1.x)
Target Version: NServiceBus 7.x

The NServiceBus.Extensions.Logging package provides support for writing NServiceBus log entries via the logging abstractions, Microsoft.Extensions.Logging, as explained in Logging in .NET Core and ASP.NET Core.

With this common logging abstraction, it is possible to log to different logging providers. Some third-party frameworks can perform semantic logging, also known as structured logging.

This package should only be used when configuring logging in a self-host model. If hosting with the .NET Generic Host use NServiceBus.Extensions.Hosting package instead.


Although NServiceBus has native support for logging frameworks like log4net, NLog, and CommonLogging, it is recommended to use Microsoft.Extensions.Logging with these frameworks for new projects.

Microsoft.Extensions.Logging can be used to replace the following providers:

Supported providers

NServiceBus supports the following logging frameworks via Microsoft.Extensions.Logging:

  • elmah.io
  • Gelf
  • JSNLog
  • KissLog.net
  • Log4Net
  • Loggr
  • NLog
  • Sentry
  • Serilog
  • Stackdriver

For an up-to-date list, see the Microsoft.Extensions.Logging fundamentals documentation, specifically the built-in and third-party providers sections.

Support for ILogger

Microsoft.Extensions.Logging abstractions provide a generic interface that allows a dependency injection-friendly way to use loggers. NServiceBus.Extensions.Logging does not register any resolver for type ILogger<TCategoryName>. Usage of ILogger<TCategoryName> requires the use an external dependency injection container like NServiceBus.Extensions.DependencyInjection that contains registrations for the Microsoft.Extensions.Logging abstractions.


Configure NServiceBus to use Microsoft.Extensions.Logging

NServiceBus.Logging.LogManager.UseFactory(new ExtensionsLoggerFactory(extensionsLoggingFactory));


Last modified