liveBook · Manning

Structured logging

As explained in Effective Behavior-Driven Development

Logging that organizes entries to convey meaningful structure, such as relationships between nested execution steps.

In test automation, scenario steps show business intent, but diagnosing failures can require details about the actions and application calls behind them. Structured logging records those details so teams can trace what happened and build confidence in the tests. section 19.3

A practical pattern is to wrap each test action’s execution in a logging scope. Indenting entries by scope makes nested work easier to follow. Record enough execution detail to support diagnosis while showing which actions were performed. section 19.3

Following a login test

A login action can log its start and result while nested entries record the REST request and response. Indentation groups those calls under the action, making the execution sequence easier to inspect. section 19.3

Listing 19.9 Hierarchical test execution log
*** Test execution result (lines trimmed for readability) ***
When the customer attempts to log in with valid password
  18:52:15 Info: Executing Login with (Rebecca, ****)...
    18:52:15 Debug: REST API request: POST /api/auth/login, Content:... 
    18:52:15 Debug: REST API response: 200 (OK), Content:... 
  18:52:15 Info: Login executed successfully in 00:00:00.2476439 with... 
-> done: AuthenticationStepDefinitions.WhenTheCustomerAttemptsToLogIn...
Then they should be authenticated
-> done: AuthenticationStepDefinitions.ThenTheyShouldBeAuthenticated...

See how indentation makes the REST request and response legible as part of the login action. section 19.3

How Effective Behavior-Driven Development covers it

How deep it goes
Shows how to wrap test-action execution in a logging scope and indent nested entries.
Examples
Uses a customer login test with nested REST API request and response logs.
What it assumes
Assumes test actions expose an execution boundary; it does not specify other required background.
What you can do after
Diagnose test failures by tracing automation actions and nested application calls.
How it connects
Connects test automation with the Test Action pattern, Infrastructure Layer pattern, and AI-based log analysis.

Also explained in

Compare how 2 books explain structured logging →

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.