r/programming • • Sep 13 '13

Structured Logging Considered Harmful

http://carolina.mff.cuni.cz/~trmac/blog/2011/structured-logging/
0 Upvotes

6 comments sorted by

8

u/TotallyNotAVampire Sep 13 '13 edited Sep 13 '13

Title Considered Harmful

Still, it's an interesting article.

1

u/Categoria Sep 13 '13

How about "Scrap Your Structured Logs" instead?

Joking aside, the title is meant in a completely tongue-in-cheek way. I doubt anyone interprets it literally nowadays.

10

u/[deleted] Sep 13 '13

It's an interesting article but I disagree with many of his premises and conclusions.

Look at his first two points:

  • Any generic log parsing tool WILL need to handle unstructured text. Always.

  • Any structured logging format WILL be used inconsistently.

Perhaps this is true for large legacy projects, but if you start a new project, why exactly can't you simply define your logging system in advance, and enforce the conventions by only allowing the interface you want?

There are other straw men all through the article:

Programmers just won’t use a structured logging API in that situation; you probably can persuade a person to replace

assert(index >= 0);

with

my_assert(index >= 0, "index file corrupted");

but we can’t expect that they will write 5 lines of code to properly log this in a structured format;

WTF? Who would write an assertion system where you needed five lines of code per instance to get the right output??

You would simple write my_assert so that its output IS in a structured format, and so that the second line generates reasonable answers.

Basically, his argument seems to be that programmers will work aggressively to foil any attempt to standardize logging in an organization. Why would you hire such prima donnas?

And, honestly, most programmers consider logging a necessary evil, not a place to show off their creativity. I'm not sure I've met one programmer who wouldn't greet a standardized logging system that produced easily parseable and searchable logs with a great deal of enthusiasm - "Less for me to think about, now I can get onto my real work."

4

u/oldneckbeard Sep 13 '13

Maybe you can't deal with it, so as a counterpoint to your stuff, here's the enterprise take on this in the Java world:

  1. All logging goes through slf4j interface.

  2. Back slf4j with logback.

  3. Use the MDC feature of logback to include application-specific diagnostic info.

  4. Use the logstash appender to log those messages to JSON format on disk.

  5. Use logstash to aggregate the logs from several servers, and using an output that sends it to...

  6. Use ElasticSearch or MongoDB to provide the long-term, fault-tolerant, programmatically searchable distributed storage.

Bam, structured logging without custom parsing, aggregated across all your instances (because you're write a fault-tolerant distributed system, right?), in a searchable interface.

1

u/satayboy Sep 13 '13

The site is down.

4

u/rozzlapede Sep 13 '13

Posting links on Reddit to underpowered university hosts considered harmful.