No doubt there is a place (or indeed a need) for debug (or trace) logging in environments where you can’t simply pause execution. However, in development environments you would be foolish not to use the (vastly superior) tooling available. I think many developers shy away from debuggers simply because they haven't taken the time to understand how to use them effectively, whereas everyone knows how to write a log stat…
You say “cave dweller debugging”, I say debug logging
31–40 of 139 posts
Re: You say “cave dweller debugging”, I say debug logging
#32I use a combination of both. Logging usually requires less setup overhead, so I often opt for that. Sometimes though, the path it takes for the code to reach the part I'm interested in can be pretty obscure. It's in these cases that the debugger truly shines. It also depends on how many things you are interested in. If you care about, say, a complex object with many properties, then the interactivity of a debugger tr…
I feel that it is the opposite. It is where the path is obscure that logging works really well. It can be iteratively refined and repeated.
Re: You say “cave dweller debugging”, I say debug logging
#33I'm having the same issues... Although I'm not a full time developer, I do some small coding and I'm also sort of responsible for the dev team. I rarely use a debugger. I do most of debugging through logging. There are 2 advantages that I see: - it forces me to add the logs where they are needed to understand the flow of the application - it forces me to make those logs actually usable, readable and understandable De…
> Making logs during development also forces developers to make a conscious effort of finding a balance of what and when to log something, create proper debug levels not to overwhelm the logs, while still providing some useful information... The need for this balance is why I don't completely agree with the article. If I'm debugging something with log messages, I put way more detail into it than I want to see in prod…
Maybe I'm just bad at it.
Re: You say “cave dweller debugging”, I say debug logging
#34FATAL = The system is basically non-functional, even in some partially-working way. Alerts fire.
ERROR = Something went wrong in some part of the system. The system may be mostly or partially working, but an important thing is broken and should be fixed. Depending on the where the error is, it may need to be immediately addressed or at least very soon.
WARNING = Something isn't working right, but it's possibly transient and the system has was a handling this via retry or other workarounds. This should be addressed at some point if possible, but shouldn't require immediate intervention.
INFO = This is the log level that the system is designed to run at. It provides enough human-readable context to see how the system is running. Most importantly, it provides just enough information provide context to WARNINGS/ERRORS/FATALS that may occur somewhere in a given request. The goal is to balance information w/performance.
DEBUG = All the things, all the time. Default mode for developers, and when diagnosing issues that require much more depth of information than provided at INFO level. It is VERY RARE to run at this level in production, as INFO logs should provide enough request context for a developer to reproduce most issues, but can be enabled for short bursts in production on one server in a cluster, or some other limited form to capture necessary information.
A guiding philosophy on all logs is to persist them in a central location (and locally w/rollover just in case persistence is broken), and is to flow some request or context ID through the system so logs from a single request can be easily identified and related log statements correlated with each other.
At my last startup, it was almost a year effort to clean up the logs. Such things like app pool crash on startup were logged at DEBUG, and the application starting successfully was logged at ERROR. Combined with an effort to improve overall quality, hit a first milestone of going 3 months without the ops team requiring escalation to developers outside of business hours (i.e. they could identify and fix things based on logs). Eventually, out of business hours alerts because a "I don't remember the last one" thing.
Re: You say “cave dweller debugging”, I say debug logging
#35Replay.io lets you add print statements after the fact, without having to "attach a debugger", modify your existing code or different layers of logging.
I can't see how a thing that is basically a debugger except it remembers the program state after each statement, can possibly work without "attaching" it, or running the program under the debugger, like you would with any other debugger.
It's not like I can say, here, I've hit an error and now I want the history of the program's execution that was never recorded.
Re: You say “cave dweller debugging”, I say debug logging
#36No doubt there is a place (or indeed a need) for debug (or trace) logging in environments where you can’t simply pause execution. However, in development environments you would be foolish not to use the (vastly superior) tooling available. I think many developers shy away from debuggers simply because they haven't taken the time to understand how to use them effectively, whereas everyone knows how to write a log stat…
There are two situations that I encounter that make step through debugging difficult or impossible, and for a lot of my work both apply. A) When developing for a microcontroller (however large or small). Stepping debuggers are limited, and sometimes unavailable at all. Most are clunky. ARM is the best here. B) Running real time things. E.g. you can't step through a Bluetooth comms process because the moment you hit a…
Re: You say “cave dweller debugging”, I say debug logging
#37No doubt there is a place (or indeed a need) for debug (or trace) logging in environments where you can’t simply pause execution. However, in development environments you would be foolish not to use the (vastly superior) tooling available. I think many developers shy away from debuggers simply because they haven't taken the time to understand how to use them effectively, whereas everyone knows how to write a log stat…
Re: You say “cave dweller debugging”, I say debug logging
#38I'm having the same issues... Although I'm not a full time developer, I do some small coding and I'm also sort of responsible for the dev team. I rarely use a debugger. I do most of debugging through logging. There are 2 advantages that I see: - it forces me to add the logs where they are needed to understand the flow of the application - it forces me to make those logs actually usable, readable and understandable De…
The stages of understanding go like this, in my experience:
1. Log nothing.
2. Upon being told to log things, write mostly useless logs: "Entering f() function", "leaving f() function". When f() fails, who knows what happened?
3. Upon being taught to add context so that logs can actually be used to troubleshoot problems, "entering f() with id 123", "id is 123", "writing 123", etc.
4. Enlightenment usually comes when logs include necessary info but are not redundant, are not noisy, and can actually be used to track down problems. Of course, improvement at step 4 is always ongoing, for all of us.
Re: You say “cave dweller debugging”, I say debug logging
#39My app formats the trace log as HTML tables, and uses color to signal errors or invalid cases. Makes debugging fun.
Also, if diagnosing a problem on a customer's inaccessible machine, a log is indispensable.
Tip: close & re-open the file for each write, so the last and most important tail end of the log doesn't vanish if the app crashes.
Re: You say “cave dweller debugging”, I say debug logging
#40No doubt there is a place (or indeed a need) for debug (or trace) logging in environments where you can’t simply pause execution. However, in development environments you would be foolish not to use the (vastly superior) tooling available. I think many developers shy away from debuggers simply because they haven't taken the time to understand how to use them effectively, whereas everyone knows how to write a log stat…