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.10.tar.gz (48.5 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.10-py3-none-any.whl (41.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: django_log_panel-0.1.10.tar.gz
  • Upload date:
  • Size: 48.5 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.10.tar.gz
Algorithm Hash digest
SHA256 5ca7a2773000a3d63afb60a71b2a70f2c24ee206b8de19710ea229f8b73c42fe
MD5 9f5704f9d8d56b79dbde848015a0dc61
BLAKE2b-256 5937444c69ab39329cc7dc0de4773064e922c8c25c4d85ccb8cd30242511aaf7

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_log_panel-0.1.10.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.10-py3-none-any.whl.

File metadata

File hashes

Hashes for django_log_panel-0.1.10-py3-none-any.whl
Algorithm Hash digest
SHA256 9ebc03ef6db20951423a9606ac612e17ec9263e02f1e25f6e242b03982198a7d
MD5 65beb0b4a49f80e86b2999c2d0d40ddb
BLAKE2b-256 297f2e364d105fb8a4becedfaa811f0d07772c93199cbcc0267e197bd96ea1fc

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_log_panel-0.1.10-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