

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Difficulty: 3
click for more info
Not enough gems
Cost: 6 gems
1: Structured Logging
incomplete
2: Slog Package
incomplete
3: Log Levels
incomplete
4: More Log Levels
incomplete
5: Key-Value Pairs
incomplete
6: Output Formats
incomplete
Back
ctrl+,
Next
ctrl+.
This lesson's interactive features are locked, please to keep using them
As you know, log/slog supports JSON output, as well as arbitrary custom formats, but so far we've only used text... let's change that.
JSON is great for production logging because it's easy for log aggregation and analysis tools to parse. Most log ingestion systems, such as the ELK Stack and Loki, accept JSON logs – even when they also support their own proprietary formats.
I prefer JSON logs for storage and filtering in production, but text logs for debugging and development.
Switch your file logs to JSON while keeping local terminal logs readable.
Restart your server with LINKO_LOG_FILE=linko.access.log set:
LINKO_LOG_FILE=linko.access.log go run .
Run and submit the CLI tests from the root of the Linko repo.