Skip to content

mtornwall/serilog-sinks-seq

 
 

Repository files navigation

Serilog.Sinks.Seq Build status

A Serilog sink that writes events to the Seq structured log server.

Package Logo

Getting started

To get started install the Serilog.Sinks.Seq package from Visual Studio's NuGet console:

PM> Install-Package Serilog.Sinks.Seq

Point the logger to Seq:

Log.Logger = new LoggerConfiguration()
    .WriteTo.Seq("http://localhost:5341")
    .CreateLogger();

And use the Serilog logging methods to associate named properties with log events:

Log.Error("Failed to log on user {ContactId}", contactId);

Then query log event properties like ContactId from the browser:

Query in Seq

The sink supports durable (disk-buffered) log shipping, and can take advantage of Seq's API keys to authenticate clients and dynamically attach properties to events at the server-side. Visit the full documentation for examples.

Configuring with XML

To adjust the Seq server URL at deployment time, it's often convenient to configure it using XML <appSettings>, in the App.config or Web.config file.

Before Serilog can be configured in XML, it must be enabled using the LoggerConfiguration:

Log.Logger = new LoggerConfiguration()
    .ReadFrom.AppSettings()
    .CreateLogger();

When XML is used for configuration, it's not necessary to include the WriteTo.Seq() method. It is important however that the Serilog.Sinks.Seq.dll assembly is present alongside the app's binaries.

The two settings typically included are:

<add key="serilog:using:Seq" value="Serilog.Sinks.Seq" />
<add key="serilog:write-to:Seq.serverUrl" value="http://localhost:5341" />
<add key="serilog:write-to:Seq.apiKey" value="[optional API key here]" />

Serilog's XML configuration has several other capabilities that are described on the Serilog wiki.

About

A Serilog sink that writes events to Seq

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 95.5%
  • PowerShell 4.5%