Demo: from println to structured JSON logs
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
- Show Shop CLI with
System.out.printlndebugging. - Add SLF4J and Logback dependencies in the POM (verify versions before recording).
- Replace
printlnwithlog.infoand placeholders. - 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.
- Switch the output to JSON through Logback configuration (a JSON encoder; verify the library).
- 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.
Marking a lesson complete is optional and you can undo it any time. Your progress stays in this browser.