Design and Implement Logging

Alberto De Natale
10 min readJan 17, 2021

Some of the components that would make a comprehensive logging solution are:

  • A logging framework
  • A logging aggregator
  • A crash reporter

In this article, I will look at what they are and some of the solutions provided by Microsoft.

Assess and Configure a Log Framework

A logging framework simplifies creating logs.

It generally provides an easy way to configure:

  • A set of outputs for the log (eg. Console, Files, Databases, …)
  • Some levels that allow specifying how important the logged information is
  • A threshold, typically configurable without rebuilding, that will set the minimum level required for a log to be sent to the output

Configure Logging in .NET Core

.NET Core allows configuring logging in a file called the appsettings.json in a section named Logging.

"Logging": {
"ProviderName": {
"Category A": "Min Level A",
"Category B": "Min Level B",
"Category C": "Min Level C"
}
}

Categories follow a hierarchical structure. For instance “Microsoft.Hosting.Lifetime” is a specialization of “Microsoft.Hosting”. Specifying a level for “Microsoft.Hosting.Lifetime” would override any level set for “Microsoft.Hosting” only for “Microsoft.Hosting.Lifetime”.

--

--

Alberto De Natale
Alberto De Natale

Written by Alberto De Natale

Alberto De Natale is a passionate tech-enthusiast software developer.

No responses yet