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.