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.11.tar.gz (50.2 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.11-py3-none-any.whl (42.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: django_log_panel-0.1.11.tar.gz
  • Upload date:
  • Size: 50.2 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.11.tar.gz
Algorithm Hash digest
SHA256 6d0d95e4e624af8dff2594ea6d426ab91fdda682d45116ff2752890d062413a8
MD5 e60660ffe5d5c989ad08424ec46e7316
BLAKE2b-256 ddd0070824aff40c3fb1f6fa15c952938ff2073d12ec8b403bf0c4736ea3862d

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for django_log_panel-0.1.11-py3-none-any.whl
Algorithm Hash digest
SHA256 147f89ab563d7a3bf3c8d8a28f16af840e442e4bb56e9923c88b3c9310bd3b34
MD5 348cf0b71ba6f5cf2a73734f48223de9
BLAKE2b-256 82061bcf028f533b21b2939fed3e1746a6c2d74597784b224f02fa0b39c7ffca

See more details on using hashes here.

Provenance

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