Skip to content

Logging

derekgreer edited this page Jun 14, 2012 · 2 revisions

RabbitBus logs key events through the use of an ILogger interface. This allows consuming applications to adapt to their logging strategy of choice (e.g. log4net, NLog, etc).

To configure logging, you first need to provide an implementation of RabbitBus.Logging.ILogger. The following implementation simply logs all output to the console:

class RabbitBusConsoleLogger : ILogger
{
	public void Write(LogEntry logEntry)
	{
		Console.WriteLine(string.Format("{0}:{1}", logEntry.Severity, logEntry.Message));
	}
}

To configure RabbitBus to use our logging adapter, the WithLogger() method is invoked with an instance of ILogger:

_bus = new BusBuilder()
	.Configure(ctx => ctx.WithLogger(new RabbitBusConsoleLogger())
			.Publish<StatusUpdate>()
				.WithExchange("status-update-exchange"))
	.Build();
Clone this wiki locally