You are currently browsing the category archive for the ‘nservicebus’ category.

NServiceBus can be configured for logging with log4net.  It is also a good practice to keep your logging configuration in a separate file.

In your [web | app].config file add the following lines:

   1: <configSections>

   2:     <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net"/>

   3: </configSections>


   5: <log4net configSource="log4net.config" />

In your service bus bootstrap code simply add Log4Net() extension method:

   1: var bus = NServiceBus.Configure

   2:    .WithWeb()   // in a web context

   3:    .Log4Net()   

   4: // rest of config ommitted

That’s it!  Remember you can control the logging level within the configuration file also by specifying the namespace and the logging level.

The following configures the NServiceBus.Utils and NServiceBus.Unicast to log only INFO levels:

   1: <logger name="NServiceBus.Utils">

   2:   <level value="INFO" />

   3: </logger>


   5: <logger name="NServiceBus.Unicast">

   6:   <level value="INFO" />

   7: </logger>