NServiceBus Host Logging Configuration

Component: NServiceBus Host
NuGet Package: NServiceBus.Host (7.x)
Target Version: NServiceBus 6.x
Standard support for version 6.x of NServiceBus has expired. For more information see our Support Policy.
For endpoints using NServiceBus version 7 and above, it is no longer recommended to use the NServiceBus Host. Use alternative approaches such as Generic Host, NServiceBus Windows Service or NServiceBus Docker Container instead. With NServiceBus version 8, the NServiceBus Host is no longer supported. Refer to the the host upgrade guide for further details and alternatives.

This article explains how to customize the logging configuration when using the NServiceBus host. For more details about logging configuration with the built-in profiles, refer to the NServiceBus.Host Profiles - Logging section.

Constructor of IConfigureThisEndpoint implementation

Logging should be customized in the constructor of the class that implements IConfigureThisEndpoint. This is recommended, as this class is the earliest opportunity to initialize any custom logging framework.

If logging is not initialized in the constructor and anything goes wrong during startup of the NServiceBus.Host, errors could be written to the default NServiceBus logging location, and not in the expected custom log output location(s).

Via endpoint configuration

To change the host's logging configuration, implement the IConfigureThisEndoint interface. Provide the custom configuration in the Customize method:

class CustomLogging :
    public void Customize(EndpointConfiguration configuration)


Related Articles

Last modified