How to Send Umbraco Logs to Logentries with log4net and LeAppender

A legacy Umbraco and log4net walkthrough for sending application logs to Logentries with LeAppender and resolving assembly conflicts.

Article guideContents, topics, tags, and RSS
Get new notes via RSS

While building an older Umbraco site, I wanted to send log4net events to Logentries. The normal setup installed a NuGet appender and configured it in log4net.config. That conflicted with the copy of log4net bundled with this Umbraco release and caused the site to fail at startup.

This was the resulting assembly error:

Log4Net Umbraco Error

The workaround kept Umbraco’s log4net assembly available under a different filename, then installed and configured the Logentries appender. The steps below are retained for that historical stack.

Fixing the error

First, add the exact log4net assembly used by the matching Umbraco release to the project.

  1. Download the same Umbraco version used by the site and locate its log4net.dll.
  2. Extract the file and add it to the Visual Studio project.
  3. Rename it; this example uses log4net.umbraco.dll.
  4. In the file properties, set Build Action to None and Copy to Output Directory to Copy if newer.
  5. Build the project and confirm that the file appears under bin\Libraries\log4net.umbraco.dll.

The historical project then added the required assembly configuration to web.config.

Installing Logentries Appender

The original setup installed the Logentries appender with Install-Package logentries.log4net. This added the target library and its log4net dependency.

Configure log4net to use Logentries Appender

Open config/log4net.config, the default location in this version of Umbraco.

Add the following appender to log4net.config:

<appender name="LeAppender" type="log4net.Appender.LogentriesAppender, LogentriesLog4net">
  <immediateFlush value="true" />
  <debug value="true" />
  <useHttpPut value="false" />
  <useSsl value="false" />
  <layout type="log4net.Layout.PatternLayout">
    <!-- Format retained from the historical Logentries integration. -->
    <param name="ConversionPattern" value="%d %logger %level% %m%n" />
  </layout>
</appender>

Add the log token to log4net.config:

<appender name="LeAppender" type="log4net.Appender.LogentriesAppender, LogentriesLog4net">
    <token value="YOUR-LOG-TOKEN" />
    ...
</appender>

Alternatively, put it in web.config:

<appSettings>
    <add key="Logentries.Token" value="YOUR-LOG-TOKEN" />
</appSettings>

If the settings do not load, the old application may need the following line in AssemblyInfo.cs:

[assembly: log4net.Config.XmlConfigurator(ConfigFile="[config filename]", Watch = true)]

To replace the default appender, change the root appender-ref from AsynchronousLog4NetAppender to LeAppender:

<root>
  <priority value="Info"/>
  <appender-ref ref="LeAppender" />
</root>

Testing the logger

This example sends one debug event and one information event during application startup:

public class StartUpLogger : ApplicationEventHandler
{
    private static readonly ILog Log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);

    protected override void ApplicationInitialized(UmbracoApplicationBase umbracoApplication,
    ApplicationContext applicationContext)
    {
        Log.Debug("This is a DEBUG message");
        Log.Info("Here is a INFO message");
    }
}

For a current Umbraco application, use the built-in Serilog pipeline and the supported sink for your chosen observability platform instead of adapting this log4net integration.

Johan Boström smiling in a navy jacket and white shirt.
Author portrait

About the author

Johan Boström

Technology leader · Solution architect · Developer

My primary work is leading developers and working as a solution architect. I still develop when hands-on work helps the team or the solution.

I mainly work across systems, integrations, and AI. This archive keeps the practical details, lessons, and implementation notes worth finding again.