Logging - NimbusAPI/Nimbus GitHub Wiki
In any real world application you want some form of instrumentation. With Nimbus we've added logging hooks into the bus, but not tied it to any specific logging library.
Which leaves you free to implement your own logging provider. We've got two already for you, a Console logger for development and thanks to Nick Blumhardt we also have a Serilog implementation.
To get Serilog install the package via Nuget
Install-Package Nimbus.Logger.Serilog
Then you can register the logger with your container and it will get passed to Nimbus.
builder.RegisterType<SerilogStaticLogger>()
.AsImplementedInterfaces()
.SingleInstance();
Of course you can register a console logger with your container if you really want to.
builder.RegisterType<ConsoleLogger>()
.AsImplementedInterfaces()
.SingleInstance();
Also you need to tell the BusBuilder to use the SerilogLogger during the configuration, otherwise the default is NullLogger.
Assuming you are using Autofac & Nimbus.Logger.SeriLog Extension.
Add chain below method when you register your BusBuilder.
.WithSerilogLogger()
ex:
builder.Register(componentContext => new BusBuilder()
.Configure()
.WithTransport(new WindowsServiceBusTransportConfiguration()
.WithConnectionString(connectionString)
)
.WithNames("Maker", Environment.MachineName)
.WithTypesFrom(typeProvider)
.WithSerilogLogger()
.WithAutofacDefaults(componentContext)
.Build()
)
.As<IBus>()
.AutoActivate()
.OnActivated(c => c.Instance.Start())
.SingleInstance();