logfmt reads structured logs from stdin and formats into readable output
Download the latest binary for your platform (Linux, macOS, Windows) from the Releases page.
go install github.com/thdxg/logfmt@latest$ go run ./cmd/autoscaler 2>&1 | logfmt
2026-02-10 12:18:55 INFO Autoscaler started
2026-02-10 12:18:56 DEBUG Scaler registered target.id=7bfc2889-8fc2-4b31-b309-80fd8984628b target.name=RAG
2026-02-10 12:18:56 INFO Manager started interval.metric=5s interval.scale=10s
2026-02-10 12:19:01 DEBUG Metric fetched target=RAG value=0
2026-02-10 12:19:01 INFO Tick metric success=1 total=1You can configure logfmt using command line flags, environment variables, or a config file (.logfmt.yaml in home or current directory).
logfmt -time-format "15:04:05" -level-format=short -no-color-time-format: Timestamp format (Go layout). Default:2006-01-02 15:04:05-level-format: Level style (full,short,tiny). Default:full-no-color: Enable/disable colored output. Default:true-hide-attrs: Show only time, level, and message. Default:false
LOGFMT_TIME_FORMATLOGFMT_LEVEL_FORMATLOGFMT_COLORLOGFMT_HIDE_ATTRS
I've been using libraries like tint to format structured logs in my Go projects.
Formatting logs is primarily for better readability during local development, but using a library for this means adding an unnecessary dependency to your project.
Having a customizable local command line tool to format any kind of json logs solves this problem.
