Getting Started
Architecture
NServiceBus
Transports
Persistence
ServiceInsight
ServicePulse
ServiceControl
Monitoring
Samples

Default Logging

Component: NServiceBus
NuGet Package: NServiceBus (8.x)

Introduction

This sample shows the default logging functionality in NServiceBus.

Verifying that the sample works correctly

Inside the [path_to_the_sample]\bin\[Debug/Release] directory should be created a log file called nsb_log_[current_date]_0.

Enabling Logging

var defaultFactory = NServiceBus.Logging.LogManager.Use<NServiceBus.Logging.DefaultFactory>();

// The default logging directory is HttpContext.Current.Server.MapPath("~/App_Data/") for websites
// and AppDomain.CurrentDomain.BaseDirectory for all other processes.
defaultFactory.Directory(".");

// Default is LogLevel.Info
defaultFactory.Level(NServiceBus.Logging.LogLevel.Debug);

var endpointConfiguration = new EndpointConfiguration("Samples.Logging.Default");

Related Articles