Trace/Verbose
Use this logging level to help you develop or find bugs in something you’re currently working on, and when the information being logged is not useful once the current task is done. So, trace logging should usually be removed when the task is done, which often means that it should not be committed. Pair this with ‘TODO-XXXX‘ to help prevent accidental commits.
Debug
Debug logging provides information that might be useful to developers while they’re working on other tasks (related or unrelated). Examples might include “The client’s session has been cleared because they logged out,” or “A feature has been hidden because a camera was not detected on this device.”
Info
Info provides information that is likely to be useful in a production environment, or in the case of client apps, information that might be useful to developers of other apps. Info logging might tell us that initialization has been completed, help identify that a particular web server is misbehaving (perhaps by the lack of certain info statements appearing), or help look into issues that are only happening in production.
In a web application, info might tell us about the things we want to know are occurring during normal operation, such as the user accounts being created or 3rd-party account connections being created.
In a client application (such as one on Android or iPhone), info might help others understand what’s going on in your application when they interact with it. For example, “A request was made by application ‘Example Application’ for user authentication, but the user denied it.”
Warn
Warn indicates that an abnormal condition occurred, but it’s not necessarily unexpected or unreasonable. It could indicate something like a bad ID was provided in the URL or that a call to a 3rd-party API failed. Such occurrences are not usually the result of a bug or coding error. Logging them is often to help us see when people, their browsers, or other websites are misbehaving, or to help us identify where we might want to add some more friendly error-handling.
Error
Error indicates a bug. For example, an if/else block might have handled all four possible values for a variable, a developer added a fifth possible value elsewhere, but didn’t add code to the if/else block to handle that value here.
Leave a Reply