Using Sitecore 8.2.
I want to log to SEQ instead of a standard file for the Sitecore log. Since Sitecore uses log4net
, I've been looking at this documentation: https://docs.getseq.net/docs/using-log4net
Here is my web.config
file:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="sitecore" type="Sitecore.Configuration.ConfigReader, Sitecore.Kernel" />
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, Sitecore.Logging" />
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<log4net>
<appender name="LogFileAppender" type="Seq.Client.Log4Net.SeqAppender, Seq.Client.Log4Net" >
<bufferSize value="1" />
<serverUrl value="http://localhost:5341" />
</appender>
<root>
<priority value="INFO" />
<appender-ref ref="LogFileAppender" />
</root>
</log4net>
I do not get anything to my SEQ installation, instead everything is still logged to file. Why is this not working?
EDIT: I've found that SEQ library can't be used, since the log4net
namespace that Sitecore uses is a special implementation that lies in the sitecore.logging dll
. I've even tried creating a custom logger and referenced it like this:
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
<log4net>
<appender name="AcmAppender" type="Coptikk.Web.Extensions.AcmAppender, Coptikk.Web">
<layout type="log4net.Layout.PatternLayout,log4net">
<param name="ConversionPattern" value="%d{ABSOLUTE} %-5p %c{1}:%L - %m%n" />
</layout>
</appender>
<logger name="Sitecore.SeqLog" additivity="false">
<level value="WARN" />
<encoding value="utf-8" />
<appender-ref ref="AcmAppender" />
</logger>
</log4net>
</sitecore>
</configuration>
I then made an alias for the Sitecore.Logging
reference and created the following code:
extern alias SitecoreLog;
using System;
namespace Coptikk.Web.Extensions
{
public class AcmAppender : SitecoreLog::log4net.Appender.AppenderSkeleton
{
protected override void Append(SitecoreLog::log4net.spi.LoggingEvent loggingEvent)
{
var lvl = loggingEvent.Level.Name;
Console.Write(lvl);
}
}
}
This works as long as there is no log4net.dll
in the bin folder. If I add the log4net.dll
that I need to send stuff to SEQ, this stops working. At this point I'm pretty blank as how to proceed.
/sitecore/admin/showconfig.aspx
page to see if proper appender is set there