Logging in ASP.NET Core 5 using Serilog

This page summarizes the projects mentioned and recommended in the original post on dev.to

InfluxDB - Power Real-Time Data Analytics at Scale
Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.
www.influxdata.com
featured
SaaSHub - Software Alternatives and Reviews
SaaSHub helps you find the best software and product alternatives
www.saashub.com
featured
  • Serilog

    Simple .NET logging with fully-structured events

  • Serilog is one of the most famous logging libraries for .NET applications. As per NuGet, the total downloads of this library already crossed 175M which clearly shows the popularity of this library among .NET developers. It is easy to set up and provides a huge collection of powerful features. It is portable between different .NET platforms and also provides a clean API. It has many extension points that allow developers to plug their custom code into it and extend the functionality of this cool library even further. In this tutorial, I will show you how to set up this library and start using it within minutes. I will also cover how you can log output in text and JSON format and at the end of this tutorial, I will show you how you can log messages to text based log files.

  • serilog-aspnetcore

    Serilog integration for ASP.NET Core

  • Serilog is a structural logging library for.NET applications that can be used for adding some cool diagnostic features to your application. This library provides a huge collection of new logging related features that are not available in the .NET built-in logging framework. It allows developers to log their messages to hundreds of different destinations including files, the console, on-premises, and cloud-based log servers, databases, and message queues. It also has native support of producing log output in plain text and JSON formats. It supports rich integration with .NET Core including ASP.NET Core. You can read the full list of features available here.

  • InfluxDB

    Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.

    InfluxDB logo
  • serilog-sinks-console

    Write log events to System.Console as text or JSON, with ANSI theme support

  • Serilog.Sinks.Console – To write log events to the Windows Console or an ANSI terminal via standard output

  • serilog-sinks-file

    Write Serilog events to files in text and JSON formats, optionally rolling on time or size

  • So far, I was only using the basic .NET logging infrastructure so it is now time to configure the Serilog library. Serilog can be downloaded and installed as a NuGet package and because I will be using Serilog in ASP.NET Core application in this tutorial so I will also install Serilog.AspNetCore package. I will also install Serilog.Sinks.File sink from Nuget as I want to show you how to log events to files later in this tutorial. You can download and install all of these packages using the NuGet Package Manager available in Visual Studio.

  • serilog-sinks-email

    A Serilog sink that writes events to SMTP email

  • Serilog.Sinks.Email – To send log events by SMTP email

  • serilog-sinks-mssqlserver

    A Serilog sink that writes events to Microsoft SQL Server and Azure SQL

  • Serilog.Sinks.MSSqlServer – To write log events to Microsoft SQL Server

  • serilog-settings-appsettings

    An <appSettings> configuration reader for Serilog

  • The first thing you need to do is to remove the built-in .NET logging configuration from the appsettings.json file. This is because the Serilog uses a simple C# API to configure logging. If you still want to use an external appsettings.json file to configure Serilog then you have to download and use Serilog.Settings.AppSettings (.NET Framework) or Serilog.Settings.Configuration (.NET Core) packages. For now, I will configure Serilog using C# code so I am commenting on the following “Logging” section from the project appsettings.json file.

  • SaaSHub

    SaaSHub - Software Alternatives and Reviews. SaaSHub helps you find the best software and product alternatives

    SaaSHub logo
NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts

  • Logs Estruturados com Serilog e Seq: Melhorando a Visibilidade e Análise de Dados em Aplicações

    6 projects | dev.to | 9 May 2024
  • SeriLog color themes

    3 projects | dev.to | 19 Feb 2023
  • ILogger

    2 projects | /r/csharp | 21 Mar 2022
  • What every ASP.NET Core Web API project needs - Part 1 - Serilog

    6 projects | dev.to | 27 Feb 2021
  • Google reCaptcha v3 server-side validation using ASP.NET Core 5.0

    2 projects | dev.to | 23 Feb 2021