In a monolith, you look at one log file. In microservices, a single user request might span 10 services. If you have 10 separate log files, debugging a single error becomes impossible. Distributed Logging centralizes all logs into one searchable database.
Never log simple strings like Log("User logged in"). Use Structured Logging: Log("User {UserId} logged in from {Ip}", user.Id, ip). This allows you to filter and query your logs like a database (e.g., "Show me all errors for User #55 across all services").
Every microservice sends its logs over the network to a central server. SEQ is a popular choice for .NET developers because it is easy to set up and provides a powerful UI for filtering logs by CorrelationId.
Q: "What is a CorrelationId and why is it the most important part of distributed logging?"
Architect Answer: "A CorrelationId is a unique GUID generated at the very first entry point (the API Gateway). This ID is passed in the header of every internal HTTP or Message call. When every service includes this ID in its logs, we can search for that one ID in SEQ and see the entire 'Life Story' of a request as it travelled through the system, even if it touched 20 different servers. Without CorrelationIds, distributed debugging is just guesswork."