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

