Skip to main content

LoggerAI for Python

Performance monitoring, errors, logs and health checks for FastAPI, Starlette, Django, Flask and Celery, with AI that explains what went wrong.

  • Every endpoint timed under its route template (/orders/{order_id}): p50/p95/p99, Apdex, status codes, slow and failed requests.
  • What each request waits on: database queries (SQLAlchemy and Django), outgoing HTTP (httpx, requests), Redis.
  • Exceptions, grouped by cause, with stack traces that show your code first.
  • Logs at warning and above.
  • Health checks you define (database, cache, a queue).
  • Background work (Celery tasks, scripts) timed like requests.
  • Browser sessions recorded by LoggerAI's browser script link to the server request each click caused (traceparent, x-loggerai-session).

The package is loggerai-sdk; you import it as loggerai.

Secrets (passwords, tokens, cookies, API keys, JWTs) are masked before anything leaves your server, request and response bodies are never sent, and users are counted by a one-way hash of their id. No dependencies; Python 3.8+.

Install

pip install loggerai-sdk

Get your project's secret key (sk_live_...) from LoggerAI → your project → Connect, and set it in the environment:

LOGGERAI_KEY=sk_live_...
LOGGERAI_RELEASE=$GIT_SHA      # optional: "since release X"

Without a key nothing is recorded or sent, so local development stays quiet.

Check it can reach LoggerAI from your server (or container):

python -m loggerai test

FastAPI / Starlette

import loggerai
from loggerai.asgi import LoggerAIMiddleware

loggerai.init()
app = FastAPI()
app.add_middleware(LoggerAIMiddleware)

Django

# settings.py
import loggerai
loggerai.init()

MIDDLEWARE = [
    "loggerai.django.LoggerAIMiddleware",   # first
    ...
]

Flask

import loggerai, loggerai.flask

loggerai.init()
app = Flask(__name__)
loggerai.flask.instrument(app)

Celery

import loggerai, loggerai.celery

loggerai.init(service="worker")
loggerai.celery.instrument()

Any other WSGI app

from loggerai.wsgi import LoggerAIMiddleware
application = LoggerAIMiddleware(application)

Health checks

def database():
    with engine.connect() as c:
        c.execute(text("SELECT 1"))
    return True               # or (False, "why")

loggerai.init(health_checks={"database": database, "redis": lambda: r.ping()})

They run every minute in the background and show on the project's health page; alert on them from the dashboard.

More

loggerai.set_user(request.user.id)          # only a one-way hash is sent

with loggerai.measure("api.stripe.com", "POST"):   # calls it can't see itself
    stripe.PaymentIntent.confirm(intent_id)

with loggerai.track("job", "send_invoices"):       # scripts, cron jobs
    send_invoices()

try:
    risky()
except ValueError as e:
    loggerai.capture_exception(e, order=order.id)  # handled, but worth seeing

loggerai.flush()     # at the end of a short script or a serverless call

Settings

Environment init() Default
LOGGERAI_KEY key — Secret key; off without it
LOGGERAI_SERVICE service app Name this process (api, worker)
LOGGERAI_ENVIRONMENT environment production Separates production from staging
LOGGERAI_RELEASE release — Version or git SHA
LOGGERAI_ENABLED enabled true Turn it off without removing the key
logs_level "WARNING" Lowest log level sent; None for no logs
ignore_paths /health, /up, … Paths not recorded
capture_queries, capture_http, capture_redis True
flush_interval 5 Seconds between batches

How it sends

Records are kept in memory and sent from a background thread every few seconds, gzipped, with a 2-second timeout. Requests never wait on LoggerAI. If it can't be reached, records are dropped instead of piling up. With gunicorn or uWSGI, each worker process sends its own batches.

Support

dev@loggerai.uk · https://loggerai.uk

Metadata

Release files for loggerai-sdk 0.1.1

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

Source distribution (sdist)

Source distribution for loggerai-sdk 0.1.1
File Size Uploaded Provenance
loggerai_sdk-0.1.1.tar.gz 19.2 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for loggerai-sdk 0.1.1
File Interpreter ABI Platform
loggerai_sdk-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 40.8 kB

Release files / loggerai_sdk-0.1.1.tar.gz

Download URL loggerai_sdk-0.1.1.tar.gz
Size 19.2 kB
Tags Source
SHA-256 checksum
How to use checksums
ea32dd652a6b536aaba1f2b9d021f09d03b008650a6c0458bf57156d9cfba96f
BLAKE2b-256 checksum
How to use checksums
ad7d5ef14d15b871a6fc0d7f6f6898998256e7c0aabeb04294913f7b52ac67ca
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 19, 2026.

Transparency log

Release files / loggerai_sdk-0.1.1-py3-none-any.whl

Download URL loggerai_sdk-0.1.1-py3-none-any.whl
Size 21.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6146203e2123c2e9e2d5d041ee603466b3a2362767eaee4c77c89115c7059601
BLAKE2b-256 checksum
How to use checksums
36d63746c49c2236ef5743f896cbdd26781b5c68b6663bdc72f0974a1a184ee9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 19, 2026.

Transparency log

Security for loggerai-sdk 0.1.1

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

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for loggerai_sdk-0.1.1.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 Oct 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.

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