We're sorry but this app doesn't work properly without JavaScript enabled. Please enable it to continue.

This lesson's interactive features are locked, please to keep using them

Output Formats

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.

Assignment

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.