2
votes

I would like to implement ReBus logging with Nlog.

We have NLog running to console, file and Database (with custom fields) and different files. I mean, NLog is up & running fine.

We have installed ReBus.Nlog Nuget Package and changed our adapter configuration to Nlog().

But nothing is logged to files in spite of we have it configured with 'Trace' loglevel.

Somebody has any simple example to implement loggin with NLog in ReBus? I have checked the tests on Rebus.Nlog github source code, but I think it is only testing explicit sent messages to logger.

Mainly I would like to log Rebus warnings and errors.

Thanks.

1
Please share your NLog configJulian
I have not changed my NLog configuration xml file since before adding NLog as the logger for Rebus. I think it must run anyway with this old/previous configuration. All the other Log's (with NLog also), are running fine. Anyway I will try to do a spike of Rebus + Nlog (so I can publish all the content) and sent to all in this thread.ferpega

1 Answers

0
votes

I have added this Logging sample project to the RebusSamples repository – the relevant part of the code is shown here:

// configure NLog
var configuration = new LoggingConfiguration
{
    LoggingRules = { new LoggingRule("*", LogLevel.Debug, new ConsoleTarget("console")) }
};

LogManager.Configuration = configuration;

// configure Rebus
Configure.With(activator)
    .Logging(l => l.NLog())
    .Transport(t => t.UseInMemoryTransport(new InMemNetwork(), "logging"))
    .Start();

As far as I can tell, this way of configuring NLog may not be the idiomatic way, since I guess most people prefer to be able to configure rules and targets with XML in their application configuration files.

Either way, NLog ends up having the static configuration applied, and then Rebus can pick that up when you call NLog() on its logging configurer.

I hope that helps :)