Golang Logging Best Practices
Table of Contents
- Golang Logging Best Practices
- Only use PCG logger
- Conform to circle logging level standard
- Do not add additional logging, unless you are suppressing the error
Only use PCG logger
- PCG logger is the standard logger for Circle services. It is a wrapper around the standard golang logger, with additional features like log rotation, log level, and log format.
Conform to circle logging level standard
- Conform to circle logging level standard. The standard is as follows:
- Debug - Can be used for diagnostic information and are more verbose. Most service do not produce log in staging and production for debug level
- Info - Normal behavior of the application. These logs state what happened.
- Warn - Something went wrong. Does not necessarily need immediate attention but should be examined eventually. Not needed if we expect the issue to resolve.
- Error - Something went wrong. Needs immediate attention. On-call engineer will be paged (phone call, voicemail, text message, email)
Do not add additional logging, unless you are suppressing the error
- PCG would already log most of the errors, both during API request handling and worker processing. Adding additional logging would only make the log duplicate and harder to debug.
- If you are sure the error is not caught already, you may log it.
Last updated on