Ready to get going? Start your 14 days free trial today

Start free trial

Have an account? Sign in

Send data via Serilog to your Logstash instance provided by Logit.io

Serilog

Ship logs from your serilog to logstash

Step 1 - InstallCopy

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

Step 2 - Configuring SerilogCopy

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="tls://your-logstash-host:your-ssl-port" />            
    </appSettings>
</configuration>

The serilog:write-to:TCPSink.uri value must be in the format "protocol://domain:port".

Step 3 - Using SerilogCopy

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.

Step 4 - Serilog Logging OverviewCopy

Serilog is a popular logging library for .NET and unlike many other logging libraries, it has been built with a focus on presenting log data in a structured & organised format. These event log messages & log files are preserved in the JSON format.

Without needing to alter your code, Serilog uses sinks to send logs in a text-based format to a centralised log management platform for further processing. If you can't or don't wish to use Serilog for structured logging, alternatively you can use either NLog or log4net for migrating your log data from .Net.

For alerting & monitoring, many Serilog users use an email sink for writing events to SMPT. This will quickly leave your inbox flooded when your application encounters an issue. A far less troublesome alternative to this can be to use an intuitive alerting and error monitoring platform that allows you to define alerts with a higher level of customisation & outputs to Slack, Asana, or WebHooks.

Logit provides alerting & monitoring as part of our platform that can be customised to output events to many popular third party tools. Our platform provides a completely managed Elastic Stack solution allowing you to get the best out of your .Net logs and provides a Serilog log analyser across all plans.

If you need any more help with shipping Serilog logs to Logstash our team are here to help. Feel free to visit our Help Centre or get in contact with our support team by sending us a message via live chat & we'll be happy to assist.

Toggle View

Expand View

Return to Search