NServiceBus Host Logging configuration

Component: NServiceBus Host
NuGet Package NServiceBus.Host (7.x)
Target NServiceBus Version: 6.x
The NServiceBus Host is being deprecated as of Version 9. Refer to the upgrade guide for further details.

Logging configuration

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

It is prefered to customize logging 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 :
    IConfigureThisEndpoint
{
    public void Customize(EndpointConfiguration configuration)
    {
        LogManager.Use<DefaultFactory>();
    }
}

Samples

Related Articles

  • Logging
    Manage and integrate with NServiceBus logging.

Last modified