The first item on our best practice checklist is leveled logging. When using leveled logging, there are two aspects you need to consider:
- Selecting the appropriate log level to use for each message: The majority of logging packages for Go applications support at least the DEBUG, INFO, and ERROR levels. However, your preferred logging solution might also support more granular log levels, such as TRACE, DEBUG, and WARNING.
- Deciding which log levels to actually output: For instance, perhaps you want your application to only output messages at the INFO and ERROR levels to reduce the volume of produced logs.
When debugging an application, it makes sense to also include DEBUG or TRACE messages in the logs so that you can ...