Chapter 9. Cross-cutting concerns: monitoring and logging
This chapter covers
- Monitoring in a microservice system
- Exploring structured logging and the Serilog logging library
- Adding correlation tokens to log messages
- Logging requests and request performance
- Logging unhandled exceptions
In this chapter, you’ll start using the knowledge about OWIN you gained in chapter 8 to create reusable pieces of OWIN middleware that address some important cross--cutting concerns: monitoring and logging. Both are needed across all microservices, and they play an important role in making a microservice system operation-friendly. Once your system is in production, you need to know whether all your microservices are up, which is why you need to monitor them. In addition, as discussed in chapter 6, you need good logging to be able to diagnose the system.
Here, you’ll build middleware in the context of one microservice. Then, in chapter 11, you’ll take that middleware and put it into NuGet packages, ready to be reused easily across all your microservices.