Benefits of Structured Logging

StackOverflow notes this question about structured logging, also known as semantic logging:

Structured Logging stores log entries not as simple strings, but as the placeholder strings along with the values to input there, for example:

log("User {username} reached request limit {limit} /s", "Grumpel", 200);

It names two advantages of structured logs:

  • Events are implicitly grouped. The format string operates as a group for the entries it produces.
  • Data values are kept as data. The limit above stays an integer, allowing to query the logs for all entries with e.g. limit > 150.