Getting Started
NServiceBus
Transports
Persistence
ServiceInsight
ServicePulse
ServiceControl
Monitoring
Previews
Samples

Default Logging

Component: NServiceBus
NuGet Package: NServiceBus (8-pre)
This page targets a pre-release version. Pre-releases are subject to change and samples are not guaranteed to be fully functional.

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

// No config is required in version 5 and enabled by default but when overriding logging
// ensure this happens before Endpoint.Start

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


Last modified