The Five Levels of Logging
51–60 of 61 posts
Re: The Five Levels of Logging
#52I increasingly feel that there should be two separate logs, one for the user with the Error/Warning/Info information (what the user wanted to be done and how well it went) and the other for the developer with the Debug/Trace information (capture key information about what the program was doing, especially on the interface - what files it was looking for, what database calls it did etc.). I always get complaints from…
Re: The Five Levels of Logging
#53> Connecting to server:4242 as "user":"hunter2" as an example of DEBUG logging is very wrong. Passwords should not end up in your logs, ever.
What password? All I see is * * * * * * *.
Re: The Five Levels of Logging
#54Earlier quoted context omitted.
What about FATAL errors which prevent the entire program from continuing?
Error and fatal are the same thing. If an operation fails and cannot be recovered, that's an error. There is no meaningful difference between an operation failing and the entire program failing. Or, from another perspective, keeping the program running is just another operation that can have fatal or non-fatal errors.
Re: The Five Levels of Logging
#55Re: The Five Levels of Logging
#56I increasingly feel that there should be two separate logs, one for the user with the Error/Warning/Info information (what the user wanted to be done and how well it went) and the other for the developer with the Debug/Trace information (capture key information about what the program was doing, especially on the interface - what files it was looking for, what database calls it did etc.). I always get complaints from…
Re: The Five Levels of Logging
#57I've always preferred levels of logging rather than these arbitrary names (what's the difference between trace and debug, and which one is lower level?). Give me three levels of logging, 1, 2, and 3, and then warning, and error. Maybe allow to mix and match them, if this makes sense (the typical nomenclature makes them all mutually exclusive, which is dumb). There are your five levels.
Depending on your Coding Culture, you order them based on "priority" (FATAL would have priority over all others, and therefore numbered as 1), or "importance" (FATAL would be most important, and therefore numbered 5.) Alternatively, each is a flag in a number so that they can be combined, with FATAL being 1 or 16 depending on priority vs. importance. I would argue that the names do indeed suffice to tell you their "l…
Info, Warning, and Error are degrees of Success or Fatal/Severe.
The status would then be logged in a structured manner that shows a facility code, serverity, message.
Re: The Five Levels of Logging
#58I support these 5 levels of logging, but given the discussion below I also would like to highlight a lesson from an SRE talk I once attended[citation needed] that really there are only three levels of alert: 1. DEBUG - Look at this when debugging, otherwise no one will ever see it. 2. TICKET - Open a ticket and have someone on your team look at this when it gets to the top of your queue. 3. PAGER - Drop what you're d…
Re: The Five Levels of Logging
#59Info: What is the program up to. Occasional messages that indicate it is alive and doing what is expected. Warn: Problems that you know about and wish would not happen, but do anyways. A service call has failed, unexpected input that violates the contract of the method, etc. You may be handling these conditions gracefully and/or returning an error to the caller, but still want to know when they happen. Usually you sh…
IMHO the difference between Warn and Error is that Warn is recoverable while Error is not.
If the server process handles it without crashing, is that a recovery?
A more general distinction IMO is the one presented in the article: an Error is something that should not have happened. A Warning is something that maybe should not have happened.
Re: The Five Levels of Logging
#60Talking about logging got me a rejection at Google. The very kind 22 year old interviewing me asked what my thoughts on commenting code was and I said most every time it's used as an excuse to show off a piece of overly clever code, so normally I discourage it in favor of logging, as they are code comments you can use in production. I realize now that was my first graybeard moment.
A comment is attached to code. A log is attached to an event.
Conflating those will either give you very bad logs or very bad comments.