loglayer-go is a unified logger that routes logs to various logging libraries, cloud providers, files, terminals, and OpenTelemetry while providing a fluent API for specifying log messages, fields, metadata, and errors.
Requires Go 1.25+ for the main module.
For full documentation, read the docs.
// Example using the Structured (JSON) transport.
// You can start out with one transport and swap to another later
// without touching application code.
import (
"errors"
"go.loglayer.dev/v2"
"go.loglayer.dev/transports/structured/v2"
)
log := loglayer.New(loglayer.Config{
Transport: structured.New(structured.Config{}),
// Put fields under "context" and metadata under "metadata"
// (defaults are flattened to the root).
FieldsKey: "context",
MetadataFieldName: "metadata",
})
// Persistent fields that appear on every subsequent log
log = log.WithFields(loglayer.Fields{
"path": "/",
"reqId": "1234",
})
log.WithPrefix("[my-app]").
WithError(errors.New("test")).
// Data attached to this log entry only
WithMetadata(loglayer.Metadata{"some": "data"}).
Info("my message"){
"level": "info",
"time": "2026-04-26T12:00:00Z",
"msg": "[my-app] my message",
"context": {
"path": "/",
"reqId": "1234"
},
"metadata": {
"some": "data"
},
"err": {
"message": "test"
}
}go get go.loglayer.dev/v2For detailed documentation, visit go.loglayer.dev.
Coming from loglayer for TypeScript? See For TypeScript Developers for the API mapping and Go-specific differences.
This is a multi-module repo: the framework core lives at the root (go.loglayer.dev/v2); every transport, plugin, and integration ships as its own independently-versioned Go module under transports/, plugins/, and integrations/.
- Dev-loop on-ramp (prerequisites, hooks, make targets, commits, tests, docs, releases via monorel): CONTRIBUTING.md.
- Architectural context (multi-module split, thread-safety contract, performance log, release flow internals): AGENTS.md.
transports/blank/ is the copyable template for adding a new transport, plugin, or integration; the full recipe is in AGENTS.md → Adding a new transport, plugin, or integration.
Bug reports, feature requests, and architectural questions go in GitHub Issues.
Made with ❤️ by Theo Gravity / Disaresta. Logo by Akshaya Madhavan.