Seq works best with richly-structured event data like that produced by Serilog, ASP.NET Core and NLog 4.5+.

If you currently use log4net however, you're not left out; we provide a log4net appender that writes events to Seq via HTTP.

Installing the Appender

At the time of writing, the Seq appender for log4net supports .NET 4+.


Logging performance and latency

For adequate logging performance, we recommend the use of Log4Net.Async, and show its configuration in the example below.

At the Visual Studio Package Manager console, type:

PM> Install-Package Seq.Client.Log4Net
PM> Install-Package Log4Net.Async

This will add the required assemblies to the project.

Then, add the Seq appender to your log4net configuration. This is wrapped in a Log4Net.Async AsyncForwardingAppender so that the application does not pause while log events are flushed to Seq:

<?xml version="1.0" encoding="utf-8" ?>
    <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
    <appender name="SeqAppender" type="Seq.Client.Log4Net.SeqAppender, Seq.Client.Log4Net" >
      <serverUrl value="http://localhost:5341" />
      <apiKey value="" />
    <appender name="SeqAsyncForwarder" type="Log4Net.Async.AsyncForwardingAppender,Log4Net.Async">
      <appender-ref ref="SeqAppender" />
      <level value="INFO" />
      <appender-ref ref="SeqAsyncForwarder" />

Set the serverUrl value under to the address of your Seq server.

Writing events

That's it! When you write log events to your log4net ILogger:

log.InfoFormat("Hello, {0}, from log4net!", Environment.UserName);

They'll appear beautifully in Seq.

Did this page help you?