Comment on page
Logging is one of the foundational pieces of telemetry we need to understand issues at runtime. It is therefore deemed one of the core responsibilities of developers to provide meaningful logs.
Developers should use the
logginglibrary that is part of the monorepo and is configured for local as well as production environments. Don't use other methods of logging since that could lead to log statements not getting delivered correctly to the central log store.
The logging levels to be used are
debug. Everything from level
infoand up (that's
warn) are delivered to the central log store. You can use all the levels of course but the logs with logging level lower than
infowill be discarded when deployed to one of the environments. We can change the logging level for a specific service to a lower level but that is a manual operation, to be used only as a last resort.
errorwhen you are reporting errors or exceptions.
warnwhen things are in 'suspicious' or potentially problematic state.
infowhen reaching important states - server started, user created, registration complete, etc. or anything worth knowing about
debugfor additional info.
Avoid logging at level
infoinside unbounded loops.
Don't log the same exception/error multiple times.
Do not log full personal identifiable or other sensitive information. User database IDs are preferred to users' names for example.