Logging
Logging data is a fundamental component of code monitoring and maintenance. This data can reveal information about how our code performs, where it is failing, what security concerns there might be, and more. It involves recording information about how our program runs. We can use this information for audits, debugging, and monitoring.
The key aspects of logging include the following:
- Log levels: Logs are categorized based on their importance and the severity of what is being logged. Examples include
DEBUG
,ERROR
, andINFO
. - Log messages: These are the narrative descriptions of application events.
- Log rotation: We rotate logs by archiving old logs and starting new ones. This prevents singular, large logs that can be difficult to manage and result in storage issues.
- Log targets: Targets are the storage destinations for the logs.
Now that we have a fundamental understanding of logging, let’s review some best practices.
Best practices
Our...