We will first try to understand the problem with log management in microservices:
- To log the information related to a system event and parameter as well as the infrastructure state, we will need to persist log files. In traditional .NET monoliths, log files are kept on the same machine where the application is deployed. In the case of microservices, they are hosted either on virtual machines or containers. But virtual machines and containers are both ephemeral, which means they do not persist states. In this situation, if we persist log files with virtual machines or containers, we will lose them. This is one of the challenges of log management in microservices.
- In the microservice architecture, there are a number of services that constitute a transaction. Let's assume we have an order placement transaction where service A, service B, and service C take part in the transaction. If, say, service B fails during the transaction, how are we going to understand and capture this failure in the logs? Not only that but more importantly, how are we going to understand that a specific instance of service B has failed and it was taking part in a said transaction? This scenario presents another challenge to microservices.