Geta

Meny NO

Log4net Loggly Appender for EPiServer CMS

Loggly is a great cloud-based logging tool. It enables developers to centralise their logging to one convenient location, which helps reduce the time it usually takes to log into the server where the project is located, find the relevant log files, and scroll through the countless number of lines to find that one specific log entry. Needless to say, it's a useful tool indeed, and this plugin enables you to effortlessly implement this feature into your EPiServer CMS project.

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

kommentarer drevet av Disqus