liveBook · Manning

Embedded application log pattern

As explained in Effective Behavior-Driven Development

A logging pattern that includes selected application log messages within a test log to provide a single source of diagnostic information.

A failed scenario tells you what expectation was missed, but the cause may lie in an earlier application operation. The embedded application log pattern puts selected application log entries inside the test log, giving the team one place to follow the scenario and investigate the failure. section 19.7 section 19.0

An order rejected at the right point

A scenario checks that an order for five large pizzas is rejected. Its test log shows the authentication step alongside application entries for the login request and the customer logging in. The entries sit within the flow of the test rather than in a separate file. section 19.4

Keep that shared log useful rather than exhaustive:

  • Choose a default detail level that supports everyday diagnosis without burying important events. section 19.4
  • Allow a scenario tag to increase detail when investigating a flaky failure; remove the override after finding and fixing its cause. section 19.4
  • Include or exclude particular application log categories when a scenario needs more focused information. section 19.4

The aim is quick error recovery during development, not maximum logging. A hierarchical test log makes the flow easier to follow; embedding relevant application entries adds clues about what happened within that flow. Application warnings and errors can also indicate a problem even when the scenario passes. section 19.7 section 19.4

How Effective Behavior-Driven Development covers it

How deep it goes
Explains log embedding and detail controls, while leaving production logging configuration outside its scope.
Examples
Shows a pizza-order scenario whose test output nests application login entries beneath a test step.
What it assumes
Assumes automated scenarios and application logging; explains why their diagnostic output belongs together.
What you can do after
Operate/configure it by selecting default log detail and temporarily raising it for scenarios needing investigation.
How it connects
Links hierarchical test logs, scenario tags, logging levels, flaky tests, and corroboration checks.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Effective Behavior-Driven Development. The section links point to the parts of the book it draws on.