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.

NLog

NuGet Package:
NServiceBus.Extensions.Logging 2.x
Target Version:
NServiceBus 8.x
Standard support for version 8.x of NServiceBus has expired. For more information see our Support Policy.

Logging integration into the host

When using NServiceBus 10.2 or later with the .NET Generic Host, configure NLog directly on the host builder. The bridge package is not required:

var builder = Host.CreateApplicationBuilder();

builder.Logging.AddNLog();

builder.Services.AddNServiceBusEndpoint(endpointConfiguration);

For more information, see Hosting with Microsoft.Extensions.Hosting.

Usage

var config = new LoggingConfiguration();

var consoleTarget = new ColoredConsoleTarget
{
    Layout = "${level}|${logger}|${message}${onexception:${newline}${exception:format=tostring}}"
};
config.AddTarget("console", consoleTarget);
config.LoggingRules.Add(new LoggingRule("*", LogLevel.Debug, consoleTarget));

LogManager.Configuration = config;

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

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 Rule.

var config = new LoggingConfiguration();

var target = new ColoredConsoleTarget();
config.AddTarget("console", target);
config.LoggingRules.Add(new LoggingRule("MyNamespace.*", LogLevel.Debug, target));

LogManager.Configuration = config;

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