log/slog
std
Structured logging in the Go standard library
Reviewed 2026-09-30 · Package source
Recorded facts
Metadata fetched: 2026-09-30T18:12:14.979Z · Freshness: current. This is a dated snapshot; check the linked sources before adopting a package.
- Version
- go1.27.1
- Minimum Go version
- 1.21
- Licenses
- BSD-3-Clause
- Import path
- log/slog
- Capabilities
- structured-logging, json
- Dependencies recorded
- 0
Vulnerability evidence
Status: unknown. Checked: Unknown.
Vulnerability evidence is unavailable; absence of data does not mean no vulnerabilities.
Version advisories do not establish whether a vulnerability is reachable in your application.
Tradeoffs
- Custom output destinations may need a separate handler.
Install and import
Included in the Go standard library; no dependency installation is needed.
import "log/slog"
Authored example
Verification status: passed · Checked: 2026-09-30T18:16:17.639Z
Package version: go1.27.1 · Go toolchain: go1.27.1
Targets: linux/amd64, windows/amd64 · CGO: disabled
Compilation checks only this displayed example. It does not verify runtime behavior, all package features or vulnerability reachability.
package main
import (
"log/slog"
"os"
)
func main() {
logger := slog.New(slog.NewJSONHandler(os.Stdout, nil))
logger.Info("application started", "service", "example")
}
Compile verification covers this example only. It does not test runtime behavior or every optional feature.
Reproduce the compilation with pinned dependencies
Save the example as main.go alongside these files in a new directory. Use the recorded Go toolchain and CGO_ENABLED=0 to compile for a recorded target.
go.mod
module example.com/discovery/slog
go 1.27.1