Open-Source Wikis

/

MinIO

/

Packages

/

logger

minio/minio

logger

internal/logger/ is the operational and audit logging facade. Every call to logger.Info, logger.Error, logger.LogIf, or logger.AuditLog flows through this package.

Layout

internal/logger/
├── logger.go              # Top-level facade
├── logger_test.go
├── logonce.go             # Rate-limited "once per N seconds" log
├── targets.go, target.go  # Target abstraction
├── audit/                 # Audit record schema
└── target/
    ├── console/
    ├── http/
    └── kafka/

Key abstractions

Symbol What it is
logger.LogIf Logs err with context if non-nil. The most-used call in the codebase.
logger.AuditLog Emits a structured audit record. Called by every HTTP handler.
Targets Multiplex over console + HTTP + Kafka.
audit.LogIf, audit.Log Audit-channel sibling of logger.LogIf.

How it works

graph LR
    CALLER[code calls logger.LogIf] --> FACADE[logger]
    FACADE --> CONS[console target]
    FACADE --> HTTP[http target]
    FACADE --> KAFKA[kafka target]
    HTTP --> STORE[internal/store on disk fallback]
  • The console target writes to stderr in structured JSON or human-readable text depending on --quiet / MINIO_LOGGER_* env.
  • The HTTP target POSTs each record to a webhook, retrying via internal/store if the webhook is down.
  • The Kafka target is for sites that funnel logs into an existing Kafka pipeline.

Audit subpath

internal/logger/audit/ contains the AuditEntry schema (with apiVersion, time, event, api, tags, error, userAgent, etc.). Audit records are submitted to a separate set of targets configured under MINIO_AUDIT_*.

The LogOnce family in logonce.go is for noisy errors that would otherwise spam the log: it remembers the last error per identifier and only re-logs after a quiet window.

Integration points

  • Used by every package in cmd/ and most packages in internal/.
  • Targets share the on-disk queue with notification targets via internal/store.
  • Configuration: MINIO_LOGGER_WEBHOOK_*, MINIO_AUDIT_WEBHOOK_*, MINIO_AUDIT_KAFKA_* etc., parsed by internal/config/.

Entry points for modification

  • New target. Add a directory under internal/logger/target/<name>/, implement the small Target interface, register in internal/config/.
  • New audit field. Extend the AuditEntry struct in internal/logger/audit/. Be careful with backwards compatibility — audit consumers parse this schema strictly.

Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.

logger – MinIO wiki | Factory