Article guideContents, topics, tags, and 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:

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.
- Download the same Umbraco version used by the site and locate its
log4net.dll. - Extract the file and add it to the Visual Studio project.
- Rename it; this example uses
log4net.umbraco.dll. - In the file properties, set Build Action to None and Copy to Output Directory to Copy if newer.
- 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.
