Skip to content
Ameen Abozaid
In reviewJNR-006-L07

Demo: from println to structured JSON logs

  • Lesson 7 of 7
  • 11 min read
  • Junior
On This Lesson 3 topics

The content for this lesson is written and waiting for review. The outline below shows what it covers. It will be published once it is approved.

In this lesson

replace println calls with SLF4J and JSON output. Prepares JNR-006-LAB1.

Draft outline details

Step by step

  1. Show Shop CLI with System.out.println debugging.
  2. Add SLF4J and Logback dependencies in the POM (verify versions before recording).
  3. Replace println with log.info and placeholders.
  4. Planned mistake: log the card number in clear text, then spot it in the output. Fix: mask it with a helper and add a test.
  5. Switch the output to JSON through Logback configuration (a JSON encoder; verify the library).
  6. Trigger an error and show one stack trace, not two.

Check your understanding

What changed between text and JSON output?

Show answer

Only the configuration.

Practice

Apply this lesson with the module's lab, exercises and quiz.

Lab and exercises Quiz

Marking a lesson complete is optional and you can undo it any time. Your progress stays in this browser.

Type to search levels, phases, modules and lessons.