Collecting service logs
Logging is a technique that involves collecting real-time application performance data in the form of a time-ordered set of messages called a log. Here is an example of a service log:
2022/06/06 23:00:00 Service started
2022/06/06 23:00:01 Connecting to the database
2022/06/06 23:00:11 Unable to connect to the database: timeout error
Logs can help us understand what was happening in the application at a particular moment in time. As you can see in the preceding example, the service started at 11 P.M. and began connecting to the database a second later, finally logging a timeout error 10 seconds later.
Logs can provide lots of valuable insights about the component that emitted them, such as the following:
- Order of operations: Logs can help us understand the logical sequence of operations performed by a service by showing when each operation took place.
- Failed operations: One of the most useful applications of logs is the ability to see the...