MessageHandler

How to configure logging

L

Some aspects of our MessageHandler libraries, among others the outbox, the transactional and the stream processing runtimes, run on background threads.

To enable logging from these background processes, you can register tracing sinks.

Logging to console

There is a built in sink, which logs to console. It can be enabled by calling RegisterBufferedConsoleTracingSink.

public static HandlerRuntimeConfiguration AddConsoleLogging(this HandlerRuntimeConfiguration runtimeConfiguration)
{    
    runtimeConfiguration.RegisterBufferedConsoleTracingSink(StructuredTraceSeverity.Warn);

    return runtimeConfiguration;
}

Logging to Azure Application Insights

There is also an extension for logging to application insights, available in the MessageHandler.Runtime.Diagnostics.ApplicationInsights nuget package.

PM> Install-Package MessageHandler.Runtime.Diagnostics.ApplicationInsights

It can be enabled by calling RegisterApplicationInsightsTracingSink.

public static HandlerRuntimeConfiguration AddApplicationInsightsLogging(this HandlerRuntimeConfiguration runtimeConfiguration)
{    
    runtimeConfiguration.RegisterApplicationInsightsTracingSink(StructuredTraceSeverity.Warn);

    return runtimeConfiguration;
}

Sign up to our newsletter to get notified about new content and releases

You can unsubscribe at any time by clicking the link in the footer of your emails. I use Mailchimp as my marketing platform. By clicking subscribe, you acknowledge that your information will be transferred to Mailchimp for processing. Learn more about Mailchimp's privacy practices here.