Skip to main content

Django admin log viewer supporting MongoDB and SQL databases.

Project description

django-log-panel

Latest on Django Packages

django-log-panel displays your Django logs inside Django admin as a per-logger status dashboard with searchable log entries and optional threshold alerts, without a separate service to run.

Log panel dashboard showing per-logger health cards

Log panel dashboard showing a 90 day logger timeline

Log detail view with message search and paginated entries Log detail view with the level filter dropdown open

Features

  • A status-page style dashboard in Django admin, with one health card per logger.
  • A searchable, filterable log table for drilling into individual entries.
  • MongoDB and SQL storage backends, depending on how you want to store logs.
  • Threshold alerts through a Django signal that your application can react to.
  • Configurable ranges, colors, page size, title, and access control.
  • Automatic root-handler setup by default, with manual LOGGING control when needed.

Requirements

  • Python >= 3.12
  • Django >= 5.2
  • pymongo>=4.16.0,<5 only when using the MongoDB backend
  • A running, reachable MongoDB instance when using the MongoDB backend

Installation

# with uv
uv add django-log-panel

# with pip
pip install django-log-panel

For MongoDB support, install the optional extra. This installs the Python client only; you still need an actual MongoDB instance to connect to:

# with uv
uv add "django-log-panel[mongodb]"

# with pip
pip install "django-log-panel[mongodb]"

Choose a backend

Backend Use it when Retention Extra setup
MongoDB You want append-only logging with cheap writes and MongoDB TTL cleanup. Automatic TTL expiry on the collection. Install the mongodb extra, run a reachable MongoDB instance, and set CONNECTION_STRING.
SQL You want logs in a Django-managed relational database. Run the delete_old_logs management command on a schedule. Add LogsRouter, point DATABASE_ALIAS at the target database, and run the log_panel migration on that alias.

Quick start

1. Add the app

INSTALLED_APPS = [
    ...,
    "log_panel",
]

2. Configure one backend

MongoDB:

LOG_PANEL = {
    "CONNECTION_STRING": "mongodb://localhost:27017",
    "DB_NAME": "myapp_logs",
    "COLLECTION": "logs",
    "TTL_DAYS": 90,
}

This example assumes a MongoDB instance is running and reachable at localhost:27017.

SQL:

DATABASES["logs"] = {
    "ENGINE": "django.db.backends.postgresql",
    "NAME": "myapp_logs",
    "USER": "...",
    "PASSWORD": "...",
    "HOST": "...",
    "PORT": "...",
}

DATABASE_ROUTERS = [
    "log_panel.routers.LogsRouter",
]

LOG_PANEL = {
    "DATABASE_ALIAS": "logs",
    "TTL_DAYS": 90,
}

If you use the SQL backend, run the migration on the logging database:

python manage.py migrate log_panel --database=logs

3. Open Django admin

Go to Application Logs, or open:

/admin/log_panel/panel/

Once configured, any standard Python logger that flows through the selected handler will show up in the panel.

How log capture works

  • LOG_PANEL selects how the admin reads log data.
  • By default, log_panel auto-attaches the matching handler to the root logger at startup.
  • Set ATTACH_ROOT_HANDLER = False when you want full control through Django LOGGING.
  • LOG_LEVEL only affects the auto-attached root handler.
  • Stored fields come from the log record itself; LOGGING formatters do not reshape the stored data.

Full setup notes and manual LOGGING examples are in the backend guide.

Querying logs in custom views

LogManager and LogQueryset let you fetch logs outside the admin panel — in your own views, APIs, or background tasks with a chainable filter interface that works with both SQL and MongoDB backends.

Subclass LogManager and override get_queryset() to apply default role-based restrictions. The returned LogQueryset behaves like a standard Python sequence — iterate it, slice it, or pass it to Django's Paginator:

from log_panel.managers import LogManager

class OperatorLogManager(LogManager):
    def get_queryset(self):
        return super().get_queryset().filter(
            logger_names=["orders", "machines"],
            min_level="WARNING",
        )

# In a Django view:
manager = OperatorLogManager()
qs = manager.get_queryset().filter(search=request.GET.get("q", ""))

list(qs)          # all matching entries
len(qs)           # total count
qs[0:20]          # first 20 entries

# Works directly with Django's Paginator:
from django.core.paginator import Paginator
paginator = Paginator(qs, 20)
page = paginator.get_page(request.GET.get("page"))

Available .filter() arguments:

Argument Type Description
logger_names list[str] Restrict to these logger names
min_level str Minimum severity — "WARNING" includes WARNING, ERROR, and CRITICAL
search str Case-insensitive message substring
timestamp_from datetime Inclusive lower bound
timestamp_to datetime Exclusive upper bound

Advanced topics

Contributing

For local work, use the uv workflow in docs/development.md.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django_log_panel-0.1.9.tar.gz (47.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_log_panel-0.1.9-py3-none-any.whl (41.1 kB view details)

Uploaded Python 3

File details

Details for the file django_log_panel-0.1.9.tar.gz.

File metadata

  • Download URL: django_log_panel-0.1.9.tar.gz
  • Upload date:
  • Size: 47.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for django_log_panel-0.1.9.tar.gz
Algorithm Hash digest
SHA256 c47d38a646e24f1decf985ba850122e85020d764b7aa72223cfbc88f96a59ec8
MD5 ac9aadc87e5e39d0f81c3dff48a43992
BLAKE2b-256 7397ba683eb58fd95a873f14ef042e3bfbf07b33f2d048601e06a7edd220c90f

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_log_panel-0.1.9.tar.gz:

Publisher: release.yml on rreiter3/django-log-panel

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file django_log_panel-0.1.9-py3-none-any.whl.

File metadata

File hashes

Hashes for django_log_panel-0.1.9-py3-none-any.whl
Algorithm Hash digest
SHA256 18a486d691345a9e499cebcfe93c10913805f3d72482915d9d54030c3a488451
MD5 187d8cd0c492967ff2d841a1f1eb82f3
BLAKE2b-256 c6f4925a73f74edb8507acc7a4a9b9e732d9a3370aeb318c9d06a9745a4c21bc

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_log_panel-0.1.9-py3-none-any.whl:

Publisher: release.yml on rreiter3/django-log-panel

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page