1

Install

Installing Serilog You will need to add the Serilog and Serilog.Sinks.Network packages. This guide will also use appSettings to configure Serilog.

Install-Package Serilog
Install-Package Serilog.Sinks.Network
Install-Package Serilog.Settings.AppSettings
2

Configuring Serilog

Add AppSettings to your app.config or web.config.

<configuration>
  <appSettings>
    <!-- Level of logging -->
    <add key="serilog:minimum-level" value="Verbose" />
    <!-- Use the TCP Network sink -->
    <add key="serilog:using:TCPSink" value="Serilog.Sinks.Network" />
    <!-- Your logstash configuration -->
    <add key="serilog:write-to:TCPSink.uri" value="your-logstash-host" />
    <add key="serilog:write-to:TCPSink.port" value="your-port" />
  </appSettings>
</configuration>
3

Using Serilog

Create a statically accessible Logger configured from AppSettings.

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

You can now log from anywhere in your application.

Log.Information("The global logger has been configured");

Serilog is a fully featured logging framework and has many other capabilities that are not detailed here, please see the Serilog Documentation for more information.