7 Application logging

 

This chapter covers

  • Application Logging overview
  • Logging techniques using the ILogger interface
  • Unstructured vs structured Logging
  • Implementing an alternative logging framework using SeriLog

The term logging - when used in an IT context - defines the process of keeping track of all the events occurring within the application (and their context information) in a structured, semi-structured, and/or unstructured format, and output them to a dedicated view and/or storage channel. Such a channel is often called secondary to distinguish it from the primary output mechanism used by the software to communicate with the end user: the User Interface (UI).

The main purpose of logging is to keep track of the various interactions between the software and their users: state changes, access to internal resources, event handlers that trigger in response to user actions, exceptions thrown by internal modules, and so on. Since this activity monitoring task is performed while the application is actually running, each log entry is typically shown (or recorded) together with a timestamp value representing the moment when the logged event occurred.

In this chapter, after a brief overview about the concept and importance of logging, we'll learn how to create a structured logging mechanism for our Web API project using the ILogger interface, as well as some third-party components that implement it.

7.1 Application logging overview

 

7.1.1 From boats to computers

 
 
 

7.1.2 Why do we need logs?

 

7.2 ASP.NET logging

 
 
 
 

7.2.1 A quick logging test

 
 

7.2.2 Log Levels

 
 
 
 

7.2.3 Logging configuration

 
 
 

7.2.4 Logging providers

 
 
 

7.2.5 Event IDs and Templates

 
 

7.2.6 Exception logging

 
 
 
 

7.3 Unstructured vs Structured logging

 
 
 

7.3.1 Unstructured logging pros and cons

 
 

7.3.2 Structured logging advantages

 
 
 

7.3.3 ApplicationInsights Logging Provider

 
 

7.4 Third-Party Logging Providers

 
 
 

7.4.1 Serilog overview

 
 
 

7.4.2 Installing Serilog

 
 

7.4.3 Configuring Serilog

 
 

7.4.4 Testing Serilog

 
 

7.4.5 Improving the logging behavior

 

7.5 Exercises

 
 
sitemap

Unable to load book!

The book could not be loaded.

(try again in a couple of minutes)

manning.com homepage
test yourself with a liveTest