NServiceBus.Extensions.Logging 1.0.0 - New package available

Hi everyone,

We’ve just released NServiceBus.Extensions.Logging 1.0.0.

What’s New

The NServiceBus.Extensions.Logging package allows your NServiceBus endpoints to be configured with any third-party logging framework implementing the Microsoft.Extensions.Logging abstraction.

This package removes the need to use NServiceBus specific logging providers if these logging frameworks support Microsoft.Extensions.Logging.

The documentation contains an up-to-date list of existing NServiceBus logging providers that are obsolete due to these providers natively supporting Microsoft.Extensions.Logging.

Check out the NServiceBus.Extensions.Logging documentation for more information.

Where to get it

You can install the new package from NuGet.

Where do I send feedback?

To send feedback, please create an issue in the NServiceBus.Extensions.Logging repository or email support@particular.net.

With thanks,
The team in Particular

Please read our release policy for more details. Follow @ParticularNews to be notified of new releases and bug fixes.

How do you get this to work with the built-in logger? Just the vanilla, out-of-the-box one?

This what I have so far, using the other extensions libraries (hosting and DI):

public class Program
{
    public static void Main(string[] args)
    {
        var host = CreateHostBuilder(args).Build();

        var loggerFactory = new ExtensionsLoggerFactory(host.Services.GetService<ILoggerFactory>());

        NServiceBus.Logging.LogManager.UseFactory(loggerFactory);

        host.Run();
    }

    public static IHostBuilder CreateHostBuilder(string[] args) =>
        Host.CreateDefaultBuilder(args)
            .UseNServiceBus(hostBuilderContext =>
            {
                var endpointConfiguration = new EndpointConfiguration("WorkerService");

                endpointConfiguration.UseTransport<LearningTransport>();
                endpointConfiguration.UsePersistence<LearningPersistence>();

                // configure endpoint here
                return endpointConfiguration;
            });
}

I don’t see anything in the console, and it looks like everything is still logged to text. I can’t supply the logger factory inside the endpoint configuration block since I don’t have access to a container or anything.

Is it expected that I must use some 3rd-party logger with this library? And not the default one?

Actually, I’m not even sure how to use this with a 3rd party logger. The NLog example isn’t using DI or hosting. If I need an instance of the logger factory, I can’t get at that until the .NET Core host is built.

Maybe the .NET Core host library should directly support .NET Core logging, like it does DI?