Starting with NServiceBus 10.2, endpoints hosted with the .NET Generic Host using AddNServiceBusEndpoint automatically use Microsoft. with rolling file and console defaults. The DefaultFactory API shown in this sample is deprecated. See Logging for modern configuration options.
Introduction
This sample shows the built-in logging functionality in NServiceBus.
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");
Verifying that the sample works correctly
A log file called nsb_log_[current_date]_0 is created inside the [path_to_the_sample]\ directory.