Getting Started
Architecture
Transports
Persistence
ServiceInsight
ServicePulse
ServiceControl
Monitoring
Samples

NServiceBus Host Logging Configuration

Component: NServiceBus Host
NuGet Package: NServiceBus.Host (8.x)
Target Version: NServiceBus 7.x

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 class's constructor that implements IConfigureThisEndpoint. That is recommended, as the class implementing IConfigureThisEndpoint is the earliest opportunity to initialize any custom logging framework.

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>();
    }
}

Related Articles