DEV Community

Erik Dietrich for Scalyr

Posted on • Originally published at

Verbose Logging: Your Magnifying Glass for Bad Application Behavior

You probably don't think of verbose logging as the stuff that hackathons and startups are made of.  Nor would most programmers consider it an especially advanced technique.  But it is important, and enough people ask about it that it's worth covering.

In this post, we'll take a look at:

  • What verbose logging is
  • Why people use it
  • And how to both consume it and produce it from your applications

By the time you're done, you'll have a firm grasp of the technique.

Part of the reason that so many people inquire about the subject of verbose logging is that it's kind of general in the same way that searching for "logging" is general.

So let's start by at least getting more specific with a definition.

What Is Verbose Logging?

The definition of verbose logging piggybacks heavily on the idea of logging in general from your software.  So let's define logging:

In software, logging is the practice of recording to a persistent medium events that occur while the software runs.

This can cover a lot of ground, from the recording of critical errors to logging normal purchase transactions for an e-commerce app to documenting every method that the software executes.  The particulars will vary widely by the nature of the software, the preferences of the team, and the context in which the software runs.

One of the most common ways to reason about a logging approach is through the use of so-called logging levels.

These allow you to control how "chatty" your logs are, ranging from "log only critical errors" to "log everything and the kitchen sink."  And verbose logging falls at the extreme kitchen-sink end.  It's a shorthand way to express the idea that you're knowingly recording events with an extremely high rate of noise.

So "verbose logging" becomes a common shorthand and has this definition:

In software, verbose logging is the practice of recording to a persistent medium as much information as you possibly can about events that occur while the software runs.

It's also worth mentioning that verbose logging is generally a mode that you can toggle on and off.  In other words, via logging levels or a simple flag, software developers give you the ability to temporarily "go verbose" rather than adopting verbose logging as the default or only state of the software.

Why Do People Use This Technique?

Now that we've established what this is, the next question is "Why would they do it?"

You can probably infer the reasoning, to an extent.  When would people, in general, want to err on the side of furnishing too much information?

You do this when you're facing an intractable problem and are thinking that any clue might help.

So it goes with verbose logging.  You generally adopt this logging mode when you're debugging or trying to hunt down some production support issue.

If the solution isn't immediately obvious, you flip the toggle for verbose mode and hope that the upcoming flood of information proves helpful somehow.

This generally isn't the highest leverage technique.  In other words, when you enter verbose mode, grab yourself a cup of coffee and prepare to spend a while sifting through a lot of output looking for anything that seems helpful.

Consuming Verbose Logging: Some Examples

When it comes to logging, there are two main parties to the activity: the producers and the consumers.  Let's take a look at the consumption side of logging in verbose mode first, with some examples.

Operating System Logs

Your operating system produces a pretty impressive cache of logs, if you're inclined to look at them.  As a consumer, you'll rarely want to do this, except when the computer acts up.  In googling the specifics of a problem you have or asking for help in a forum, you might encounter advice to enable verbose logging for some facet of the OS.


Imagine that you're trying to install some piece of software and you get a cryptic error like, "Not Allowed, Install Aborted."

Sadly, this kind of thing happens a lot.

Software installations tend to produce logs, but those might not be enough.  And so you would reasonably turn to running the installation in verbose mode, which many installers offer.

Command Line

Perhaps the simplest, quickest example of finding verbose information happens when you go to the command line.  For instance, take the gzip command in a Linux environment.  This is one of the simplest commands imaginable--give gzip a file and it compresses or decompresses it.

But if you add the "-v" flag to it, you tell it to run in verbose mode.  It then obliges by showing you additional information that includes the compression/decompression percentage.

Troubleshooting Your Own Software

The last quick consumption example that I'll mention is one where you're responsible for the software in question.  You might be anywhere on the DevOps spectrum and in need of information for troubleshooting.

In this case, you'll typically change a configuration setting in a config file or in a database that your code uses.  "Flip to mode," you'll tell it, and then you'll start your search for the problem.

Producing Verbose Logging in Your Own Application

That provides a nice segue into the other side of things: producing verbose logging from your application.  Doing this requires, first and foremost, a relatively sophisticated approach to application logging.  You need to be doing it, of course, but you also need the aforementioned configurable log levels and a way to toggle among them.  And you should also be producing well-formatted log files, lest you bury consumers in a tidal wave of useless information.

With all of this in place, give some thought to your most verbose level of logging.

What would help with troubleshooting?  Tons and tons of context around each message?  A note about where in the code you're logging from?  An exhaustive dump of inputs to and outputs from your software?  You'll have to decide based on context.

And perhaps the most important consideration for offering a verbose mode is making the toggling easy and foolproof for anyone using it.  If you default to verbose mode or forget to turn it off, you'll quickly create unmanageable log files while making life really hard on anyone looking for basic information rather than needles in haystacks.

Looking Forward: Verbose As the New Normal

In closing, it's worth mentioning that the old pitfalls of verbose logging may be falling away with advances in technique and technology.  Verbose mode has, historically, favored the tradeoff of tons of information for difficulty finding and using the information you actually need.  But modern log management solutions are changing the game in that regard, by offering the following:

  • Taking care of log aggregation and storage for you.
  • Parsing the log messages and turning them into data.
  • Offering intelligent indexing and search.

So you should understand verbose mode for what it has historically been: a way to bury yourself in information with the hope that some of it will help.  But you should also understand it for what it's becoming: a way to have your cake and to eat it too.

Top comments (0)