Stop Using Logs Everyday

I don’t "believe" in logs, generally.

What I mean is, for developers, logs should be seen strictly as a story for ops, not a development tool. I understand why ops needs to see logs. Ops is a customer just like any other, and what they need, we can supply. But I see far too many developers use the log all day long during development.

Everyone from time to time does "print" debugging, of course. No technique on earth can entirely supplant it, cuz geekery is actually hard. Many developers, though, use a log as a permanent debug printer, and that’s a terrible way to live.

Under normal development, your program isn’t doing "bad things" except in the new area you’re working in.

I often speak of two modes: coding-on-target, coding-on-experiment. Normal development is always a mix of these.

  • When I’m coding-on-experiment, I don’t really know what I want. I am coding to a dream, some high-level idea of what might work.
  • When I’m coding-on-target I know very much what I want, or think I do, and am changing things to get that in a very direct way.

Coding-on-Target

Coding-on-target I almost always have microtests aimed at that target. I don’t need the log for a couple of reasons.

First, cuz I generally have tests when I’m coding-on-target. The tests are quite good at telling me what just happened.

Second, cuz i’m working in a very small scope. I don’t need a log cuz the scope is too small for logging info to even matter, unless, of course, i’m not using a small scope, in which case i’m screwing up, and I don’t need a log to tell me that.

Coding-on-Experiment

When i’m not coding-on-experiment, all bets are off, of course. I may or may not have tests. I may or may not be running the whole app. But even then, I don’t want to use the log. Why? Cuz the log is full of noise. Full of it. It tells you 10,000 things more than you wish.

Have you ever turned, say, a Spring-based app’s log to ‘debug’ to look at something? Hope you’ve got a lot of time and very good eyesight.

So, no. As a general rule, when I need to print-debug, and as I say, everyone needs to from time to time, I use print, not a log.

In IDE’s that put the log output in the program window, like eclipse, I turn off the log. If you’re using the log every day, you’re working testlessly, or you’re shipping too many bugs, or you don’t yet know how to structure code.

Turn Off the Log

My advice to noobs: turn off the log and find another way to tell what’s going on. It will be hard for a while, so take care of yourself, but the long-game answer to not knowing what’s going on is never "tell me everything that is going on".

The long-game answer involves a lot of behaviors that, once learned, will make you far more skilled as a developer.

What skills? Well, lemme take a few shots. I’ll prolly under-describe, but these will give you clues, anyway.

  • Learn that the heart of programming is structuring scope so that big programs fit in small brains.
  • Learn to write tests and keep them and use them all the time.
  • Learn that doing so will force your design in certain directions and accept that.
  • Learn that it’s better to only commit code that was made while you were coding-on-target, not coding-on-experiment.
  • Learn that you can change the structure of your code without changing its behavior, to create small scopes where change needs to happen.

There’s more, but it involves a course in programming, and ain’t nobody got time for all that.

Hopefully that will give you some ideas.

Start where? Start by turning off your log. Start hating print-debugging.

Want new posts straight to your inbox once-a-week?
Scroll to Top