Skip to main content

logwarden

A guardrail for logs. logwarden reads the JSON logs your service actually writes and flags every line that would make debugging harder: ad-hoc field names, missing service info, free-text events, and errors that don't say what failed. It exits with code 1 on problems, so CI and AI agents can use it the way they use tests.

It checks output, so it works for any language: JSON lines from a file or stdin, or logs sent over OTLP by any OpenTelemetry SDK. logwarden lint-code checks source code too. Field names follow OpenTelemetry semantic conventions, the names traces and metrics already use, so logs, traces and metrics can be queried together.

$ uvx logwarden check logs.jsonl
logwarden: 573 records, 2843 violations

  539	adr_event_name - Event is a constant snake_case name
	fix: Use a fixed name like import_completed and move variable data into fields
	e.g. §4: event 'Loaded 3 models' must be a constant snake_case name

findings (first 20):
  line 1	adr_event_name	§4: event 'Loaded 3 models' must be a constant snake_case name

What it checks

Rule Fails on
adr_banned_synonym status=500 instead of http.response.status_code=500
adr_semconv_prefix http_route instead of http.route
missing_attribute a field that isn't semconv and isn't declared by the project
deprecated a renamed semconv field (gen_ai.system)
adr_missing_required no service.name, service.version or deployment.environment.name
adr_environment_value dev instead of development
adr_event_name event="Loaded 3 models" instead of models_loaded
adr_failure_context an error line without exception.type, error.type or a status code
adr_sensitive_data password=..., a JWT, an API key, user:pass@ in a URL, an email or card number
adr_non_json_line a plain-text line (a library banner, a printed traceback)
adr_trace_context a trace_id/span_id that isn't W3C lowercase hex
adr_upstream_failure_coverage an upstream in upstreams whose failure path no test exercised
adr_event_catalog an event missing from the event catalog, when events is configured

The standard is in docs/standard.md, and each rule's fix is in docs/rules.md.

Use it in a project

uv add --dev logwarden                      # or: pipx install logwarden / uvx logwarden
logwarden init --agent                      # fields file + AGENTS.md section
LOGWARDEN_CAPTURE=logs.jsonl pytest         # capture logs (pytest plugin, auto-registered)
logwarden check logs.jsonl                  # check them

Other languages and Docker:

logwarden capture -o logs.jsonl -- npm test   # receive logs over OTLP while the command runs, then check
docker run --rm -v "$PWD:/work" ghcr.io/ingeniator/logwarden:0.7.0 check logs.jsonl   # no Python needed

Setup recipes whose output passes: Node (pino), Go (slog), Java (logback).

Python services can get compliant logs from one call, and test helpers for failure logs:

from logwarden.logging import configure          # pip install 'logwarden[structlog]'
log = configure(service_name="billing-api", service_version="1.4.2", environment="production")
# CI: on pull requests, compares with the base branch and comments new/fixed counts
- uses: Ingeniator/logwarden@v0.7.0
  with:
    logs: logs.jsonl
    comment: "true"             # needs permissions: pull-requests: write

Reviewing a change: check --compare base.json lists new and fixed findings against a snapshot of the base branch (check --snapshot), --html writes a self-contained report and --markdown a PR-comment summary. logwarden catalog logs.jsonl lists the events a service logs; commit them as logwarden-events.toml and check reports events that aren't in it.

Also lint the source: logwarden lint-code src/ runs logwarden's Semgrep rules (Python, JavaScript/TypeScript, Go, Java) for formatted event names, secret and banned field names, and print instead of the logger. Ruff LOG, G and TRY400 rules for Python, and sloglint for Go, cover more cases in an existing lint setup. The recommended config is in docs/integration.md §6.

Project settings go in [tool.logwarden] in pyproject.toml, or in logwarden.toml. On an existing service, logwarden baseline logs.jsonl records today's findings so CI fails only on new ones. See docs/integration.md for capturing logs from any stack, project-only fields and migrating a legacy service.

For AI agents

  • Claude Code: /plugin marketplace add Ingeniator/logwarden, then /plugin install logwarden@logwarden. This gives a skill for writing good logs, the MCP server and /logwarden:check.
  • Other agents: logwarden init --agent adds a logwarden section to AGENTS.md. The MCP server runs with uvx --from 'logwarden[mcp]' logwarden mcp and provides check_logs, explain_rule, list_rules and get_standard.
  • Machine output: logwarden check --json gives each finding's line number, rule and fix hint.
  • Agents working on this repo: read AGENTS.md.

How it works

Each log line becomes a sample for OTel Weaver registry live-check. Weaver checks the sample's field names against the semconv registry (plus logwarden's shared fields and the project's logwarden-fields.yaml) and runs the rules in src/logwarden/_data/policies/logwarden.rego. logwarden capture turns OTLP log records into the same JSON lines first. Python 3.10+ on Linux, macOS or Windows, or the Docker image (linux/amd64, linux/arm64). Weaver and the semantic conventions are downloaded on first use, checked against pinned SHA-256 sums and cached.

Roadmap

See docs/roadmap.md. Release notes are in CHANGELOG.md.

License

Apache-2.0

Metadata

Release files for logwarden 0.7.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for logwarden 0.7.0
File Size Uploaded Provenance Actions
logwarden-0.7.0.tar.gz 127.3 kB With provenance Details for logwarden-0.7.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for logwarden 0.7.0
File Interpreter ABI Platform Actions
logwarden-0.7.0-py3-none-any.whl Python 3 none any Details for logwarden-0.7.0-py3-none-any.whl

Total release size: 198.3 kB

Release files / logwarden-0.7.0.tar.gz

Download URL logwarden-0.7.0.tar.gz
Size 127.3 kB
Tags Source
SHA-256 checksum
How to use checksums
a238cbe5ff4a1b59329756f0135f824d4317b97d3f8ccd9c05e43c9782fc998c
BLAKE2b-256 checksum
How to use checksums
45ca5dfecef85e8029701fd122bc00999cd0cb4cc7486929416795f6c43322b0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 19, 2026.

Transparency log

Release files / logwarden-0.7.0-py3-none-any.whl

Download URL logwarden-0.7.0-py3-none-any.whl
Size 71.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c2197735339b1f694f4e87c8a7492b1e47e463d84edf4e3f98c6afa0c4d1421b
BLAKE2b-256 checksum
How to use checksums
d5c22a98cd0570f6f1e0f7377eca31f91aab3670d075df452ac0f2d02db2e2ed
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 19, 2026.

Transparency log

Security for logwarden 0.7.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for logwarden-0.7.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 19, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page