AI agents: use the documentation index at llms.txt to locate machine-readable pages. This section is indexed by https://docs.particular.net/samples/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 Usage

NuGet Package:
NServiceBus.Extensions.Logging 4.x
Target Version:
NServiceBus 10.x

This sample shows how to configure an NServiceBus endpoint to use NLog through the Microsoft.Extensions.Logging abstractions.

Both Microsoft.Extensions.Logging and NServiceBus.Logging are logging abstractions and both must be configured.

The following logging chain is created:

  • NServiceBus.Logging
    • Microsoft.Extensions.Logging
      • NLog.Extensions.Logging
        • NLog
          • Console output

Configure NLog

NLog in this example is configured in code:

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("*", NLog.LogLevel.Debug, consoleTarget));

NLog.LogManager.Configuration = config;

Configure logging abstractions

The following snippet shows how to register NLog as a logging provider. NLog has its own provider extensions for Microsoft.Extensions.Logging and needs an NLogLoggerFactory provider that implements an Microsoft.Extensions.Logging.ILoggerFactory instance so that Microsoft.Extensions.Logging can use NLog.

builder.Logging.AddNLog(config);

Endpoints can be created or started only after the logging initialization has completed.

Related Articles