Sitecore: logging via RabbitMQ

In previous post I’ve described why I’ve started to look into RabbitMQ integration. Here you could find its implementation.

Sitecore + RabbitMQ implementation

In order to send log data from Sitecore we need to extend its Logger. Sitecore uses logging system based on log4net (it is their own implementation and based not on the latest log4net sources) so we could try to use existing open source module from NuGet at least as a reference.

I took the module, replace log4net reference to Sitecore.Logging dll and made all needed changes. All this code you could find on GitHub in pre-beta version.

GitHub: Sitecore.Logger.RabbitMQ.GelfAppender

How to configure

  1. Put compiled DLLs to bin folder.
  2. Make changes in web.config:
    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
      <configSections>
        <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, Sitecore.Logging" />
      </configSections>
    
      <log4net>
        <appender name="rabbitmq" type="log4net.Appender.GelfRabbitMqAppender, Sitecore.Logger.RabbitMQ.GelfAppender">
          <HostName value="localhost" />
          <VirtualHost value="/" />
          <Port value="5672" />
          <Exchange value="log4net.gelf.appender" />
          <Username value="guest" />
          <Password value="guest" />
          <Facility value="SampleClient" />
        </appender>
    
        <root>
          <level value="ERROR" />
          <appender-ref ref="rabbitmq" />
        </root>
      </log4net>
    
    </configuration>
  3. Run RabbitMQ service
  4. Check that messages are sent (you need to use any kind of client AMQP)
Now we can use it.
Sitecore: logging via RabbitMQ

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s