Skip to main content

Overview

Fracta uses Go’s log/slog for structured JSON logging, wrapped by the internal/fractalog package. All log output includes a "component" tag identifying the subsystem that emitted it. Fracta also has an internal event bus for structured lifecycle and infrastructure events. The event bus does not replace slog or fractalog; it uses them through LogSink. See docs/event-bus.md for the event-bus architecture and how it relates to logging.

Configuration

Add a logging section to fracta.yaml:
Path resolution:
  • Absolute path (e.g., /var/log/fracta.log) — used as-is
  • Relative path or bare filename (e.g., fracta.log, logs/fracta.log) — resolved from the working directory where the fracta binary runs
Level precedence: logging.level in config > FRACTA_LOG_LEVEL env var > default (info) When logging.file is set, logs go to both stderr and the file. When omitted, logs go to stderr only (original behavior).

Full fracta.yaml example

Architecture

Event Bus Interaction

Logging architecture is still based on slog + fractalog. What changed with spec-28 is the path for event-style observability:
  • bus emitters send events.Event through events.Bus
  • LogSink writes the event as a normal structured log line under component events
  • StoreSink persists the event without logging again
  • K8sEventSink may also export selected events to Kubernetes Events in K8s mode
So:
  • ordinary application logs still use fractalog.Component("name") directly
  • bus events become structured log lines through LogSink
  • logging configuration and output destinations are unchanged

Usage

Struct with a logger field

Standalone function

Rules

  1. Always use fractalog.Component("name") — never bare slog.Info() or slog.Default().With("component", ...).
  2. Never use package-level var log = fractalog.Component(...) — the handler is captured at call time, which is before AttachFile runs. Always create loggers inside functions.
  3. Component names should match the package or subsystem name (e.g., "gateway", "reconciler", "serve", "worker").

Component Registry

Log Format

All output is JSON (one object per line):

Filtering Examples