AI agents: use the documentation index at llms.txt to locate machine-readable pages. This section is indexed by https://docs.particular.net/nservicebus/llms.txt. The markdown version of this page is served as plain text. An MCP server at /mcp serves the same content via the search_docs and read_doc tools; it is read-only and needs no credentials. Markdown versions of documentation pages are available by appending .md to the page URL. Directory URLs use index.md. They are served as text/plain because some retrieval backends reject text/markdown.

NServiceBus.Extensions.Logging

Target Version:
NServiceBus 10.x

The NServiceBus.Extensions.Logging package's ExtensionsLoggerFactory is deprecated starting with NServiceBus 10.2.0. When hosting with the .NET Generic Host using AddNServiceBusEndpoint, NServiceBus natively uses Microsoft.Extensions.Logging and the bridge package is no longer required. See the upgrade guide for migration details.

The NServiceBus.Extensions.Logging package provides support for writing NServiceBus log entries via the Microsoft.Extensions.Logging abstractions. 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.

Compatibility

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.

Usage

Configure NServiceBus to use Microsoft.Extensions.Logging:

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

List of Samples

Related Articles