Configuring Framework Middleware (Express, Django, Laravel)
Set up automatic request logging and error capture with framework middleware.
What Middleware Captures
All framework integrations automatically capture:
- HTTP request method, path, and status code
- Response time (duration_ms)
- Client IP and user agent
- Route pattern (if available)
- Unhandled exceptions
This data is sent to the /ingest/requests endpoint for the Requests page in the dashboard.
Express (Node.js)
JavaScript
import express from 'express';
import { init } from '@lognitor/node';
import { createExpressMiddleware } from '@lognitor/node/integrations/express';
const client = init({ apiKey: 'your-key', service: 'my-api' });
const app = express();
app.use(createExpressMiddleware(client, {
ignoreRoutes: ['/health', '/ready'],
}));Django (Python)
Python
# settings.py
MIDDLEWARE = [
"lognitor.integrations.django.LognitorMiddleware",
# ... other middleware
]
LOGNITOR = {
"api_key": "your-api-key",
"service": "my-django-app",
"capture_user": True,
"ignore_routes": ["/health"],
}Laravel (PHP)
PHP
// app/Http/Kernel.php
protected $middleware = [
\Lognitor\Integrations\Laravel\LognitorMiddleware::class,
];See the SDK reference for Fastify, Hono, NestJS, Flask, FastAPI, Symfony, and WordPress integrations.