Log4net Loggly Appender for EPiServer CMS

Dzulqarnain Nasir 03.09.2014 02:19:00

Installation

Firstly, you'll need to install the plugin via the EPiServer NuGet feed. NuGet will add the necessary files and dependencies, and also some additional lines in your EPiServerLog.config file. It should look something like the following after transformation is applied:

<root>
  <level value="Error" />
  <!-- probably some other stuff here already -->
  <appender-ref ref="loggly" />
</root>

<appender name="loggly" type="EPi.Log4NetLogglyAppender.Appender, EPi.Log4NetLogglyAppender"> 
  <endpoint value="REPLACE-THIS-WITH-YOUR-LOGGLY-ENDPOINT" />
  <token value="REPLACE-THIS-WITH-YOUR-LOGGLY-TOKEN" />
  <!-- Disable tags if running on 1st generation API -->
  <tags>tag1,tag2</tags>
</appender>

Next, replace the endpoint and token values with your Loggly endpoint and token values, and you're all set. That is, of course, assuming you have log4net set up correctly.

At this point, you're probably wondering about the warning message displayed above. The plugin is designed to work with both the older API as well as the current one. The older API does not support tags, and will return a request error if you include tags, and your log entry will not be registered. So make sure you disable tags if you're running on the older API.

That's it. Your EPiServer site should start sending log entries to your Loggly feed. In some rare cases, you might need to recycle your application pool to get it working.

Useful notes

If you haven't already set up log4net, you can enter the following line in your Global.asax.cs file.

protected void Application_Start(Object sender, EventArgs e)
{
    log4net.Config.XmlConfigurator.Configure();
}

The Application_Start function should already be there by default, and there are probably other function calls in there as well. Leave them alone, and add the above line somewhere.

Here's a direct link to the package located on the EPiServer NuGet feed: Log4net Loggly Appender

Wassalam