Skip to main content

Django Simple Log Viewer

Django Simple Log Viewer is a high-performance, intuitive log analytics dashboard and log viewer for Django applications. It automatically discovers, parses, and provides real-time monitoring, KPI analytics, 24-hour traffic activity histograms, correlation/entity trace timelines, payload sanitization, and raw log inspection across your application logs.

Django Simple Log Viewer Analytics Dashboard

Features

  • Zero-Fuss Integration: Discovers log files and formatters directly from your standard Django LOGGING configuration.

  • Log Analytics Dashboard: - KPI Metrics Cards: Total logs, file sizes, error counts, error rate percentage, warning, info, and debug counts. - 24-Hour Activity & Surge Histogram: Visual hourly traffic distribution across the day with error highlights and peak volume surge alerts. - File Switcher Bar: Visual interactive pill buttons displaying each available log file with file size badges for quick one-click switching. - Auto-Refresh: Live polling intervals (off, 5s, 10s, 30s, 60s) with spinning status indicators.

  • Request & Transaction Trace Scanner: - Trace any ID across logs: Request ID, Correlation ID, Trace ID, User ID, Task ID, Order ID, or UUID. - Date Scoping: Selected log file, all available files, or custom date range (start to end date). - Fast Mode / Severity pre-filtering: target specific log levels (e.g. ERROR) to accelerate scans. - Lifecycle Event Timeline: Automatically maps log events to structured lifecycle stages (Drafting/Creation, Scheduling, Approval, Queue & Processing, Dispatch/Delivery, Completion, Failures/Errors) with color-coded stage badges and interactive step inspection.

  • Massive Payload Sanitization & DOM Protection: - Automatically redacts voluminous JSON dumps, base64 blobs, and large arrays into concise interactive indicator pills in the list view (e.g. [/* 📦 Array (500 items) stripped */], [/* 📦 Object (8,109 chars) stripped */]). - Full raw payload is preserved and viewable on-demand in the Log Detail Modal with one-click JSON formatting and clipboard copying. - Sensitive credentials masking (Authorization Bearer tokens, passwords).

  • Fast Filtering & Search: Instant severity tabs (ALL, ERROR, WARN, INFO, DEBUG), real-time debounced keyword search with match highlighting, and pagination.

  • Export Capabilities: Export filtered logs as JSON or CSV directly from the dashboard.

  • Universal Log Format Support: - Supports %-style (%(asctime)s), {-style ({asctime}), and $-style ($asctime) formatters. - Automatically parses bracketed timestamps ([%(asctime)s]), hyphen delimiters, colons, and padded levels (%(levelname)-8s). - Handles Django documentation’s recommended formats seamlessly (including {process:d}, {thread:d}).

  • Multiline Traceback Preservation: Multi-line error stack traces and exceptions are automatically attached to their corresponding log entries and rendered cleanly with preserved formatting.

  • Rotated Logs Support: Seamlessly browses rotated log archives (e.g. app.log.1, app.log.2023-11-22).

  • Pathlib & Relative Path Support: Works seamlessly with pathlib.Path objects (e.g., BASE_DIR / 'logs' / 'app.log') and relative paths.

  • Secure Access Control (RBAC): Restricted to superusers by default, or fully customizable with custom permission functions and staff controls.

  • Dual View Modes: Sleek dark-mode Analytics Dashboard by default with instant toggle to Classic DataTables view.

Compatibility

  • Python: 3.11, 3.12, 3.13+

  • Django: 4.2 (LTS), 5.0, 5.1, 5.2+

Installation

Install via pip:

pip install django-simple-log-viewer

Quick Start

  1. Add log_viewer to your INSTALLED_APPS in settings.py:

    INSTALLED_APPS = [
        ...,
        'log_viewer',
    ]
  2. Add the log viewer to your project’s urls.py:

    from django.urls import path, include
    
    urlpatterns = [
        ...,
        path('log-viewer/', include('log_viewer.urls')),
    ]
  3. Configure a file-based handler in your LOGGING setting in settings.py (if you haven’t already):

    from pathlib import Path
    BASE_DIR = Path(__file__).resolve().parent.parent
    
    LOGGING = {
        'version': 1,
        'disable_existing_loggers': False,
        'formatters': {
            'verbose': {
                'format': '{levelname} {asctime} {module} {process:d} {thread:d} {message}',
                'style': '{',
            },
            'standard': {
                'format': '%(asctime)s [%(levelname)s] %(name)s: %(message)s',
            },
        },
        'handlers': {
            'file': {
                'level': 'DEBUG',
                'class': 'logging.FileHandler',
                'filename': BASE_DIR / 'app.log',
                'formatter': 'standard',
            },
        },
        'loggers': {
            '': {
                'handlers': ['file'],
                'level': 'INFO',
                'propagate': True,
            },
        },
    }
  4. Log in as a superuser and visit /log-viewer/ in your browser.

Settings Configuration

Every behavior and tweak of the log dashboard can be configured in your settings.py:

Setting

Default

Description

LOG_VIEWER_PAGE_SIZE

50

Default number of log rows per page.

LOG_VIEWER_DEFAULT_THEME

'dark'

Default UI theme ('dark' or 'light').

LOG_VIEWER_AUTO_REFRESH_INTERVALS

[0, 5, 10, 30, 60]

Available auto-refresh options in seconds (0 = Off).

LOG_VIEWER_DEFAULT_AUTO_REFRESH

0

Initial auto-refresh interval.

LOG_VIEWER_SANITIZATION_ENABLED

True

Strips massive payloads (large collections, huge JSON blobs) from table views.

LOG_VIEWER_PAYLOAD_MAX_LENGTH

250

Max inline string length before truncation pill in list views.

LOG_VIEWER_ARRAY_MAX_ITEMS

5

Max items shown in inline arrays before collapsing into a pill.

LOG_VIEWER_SUPERUSER_ONLY

True

Restrict access strictly to superusers (is_superuser). Set to False to allow staff.

LOG_VIEWER_PERMISSIONS_CHECK

None

Custom callable or import string "app.auth.check_perm" taking (user, request) -> bool.

LOG_VIEWER_EXCLUDE_FILES

[]

List of file names or substrings to exclude from the viewer (e.g. ['secret.log']).

LOG_VIEWER_HOURLY_CHART_ENABLED

True

Enable or disable the 24-hour traffic activity histogram.

LOG_VIEWER_REVERSE_ORDER

True

Show newest log entries first.

LOG_VIEWER_CACHE_ENABLED

True

Enable in-memory LRU caching for overview stats.

LOG_VIEWER_CACHE_TIMEOUT

15

Invalidation timeout in seconds for overview cache.

LOG_VIEWER_FILE_SEARCH_DIRECTORIES

[]

Additional filesystem paths to scan for log files.

SITE_NAME

'LogViewer'

Brand name displayed in the dashboard header.

LOG_FILE_EXTENSION

'.log'

File extension filter for log archives.

Custom Entity / Correlation Patterns

To add custom regexes for auto-extracting entity/trace IDs:

LOG_VIEWER_ENTITY_PATTERNS = [
    r'(?i)\b(?:request|request_id|trace_id)[\s:=#]+([a-zA-Z0-9_\-]+)',
    r'(?i)\b(?:correlation|correlation_id)[\s:=#]+([a-zA-Z0-9_\-]+)',
    r'(?i)\b(?:user|user_id)[\s:=#]+([a-zA-Z0-9_\-]+)',
    r'#([a-zA-Z0-9_\-]+)',
]

Custom Lifecycle Stages

Configure how unstructured logs map to chronological lifecycle timeline stages:

LOG_VIEWER_LIFECYCLE_STAGES = [
    {'name': 'Creation', 'color': 'blue', 'keywords': ['create', 'created', 'init']},
    {'name': 'Queueing', 'color': 'cyan', 'keywords': ['queue', 'queued', 'worker']},
    {'name': 'Processing', 'color': 'indigo', 'keywords': ['process', 'running']},
    {'name': 'Dispatch', 'color': 'teal', 'keywords': ['send', 'sent', 'broadcast']},
    {'name': 'Completion', 'color': 'green', 'keywords': ['success', 'completed', 'done']},
    {'name': 'Errors', 'color': 'red', 'keywords': ['fail', 'failed', 'error', 'fatal']},
]

REST API Endpoints Reference

All API endpoints inherit your RBAC permissions and return JSON:

Method

Endpoint

Description

GET

/api/overview/

Returns KPIs, severity breakdown, and 24-hour hourly traffic distribution.

GET

/api/logs/

Paged query for sanitized log rows with level and keyword filtering.

GET

/api/scan/

Entity/correlation scanner across single file, all files, or date range with lifecycle mapping.

GET

/api/detail/

Returns complete un-sanitized raw payload and formatted JSON for inspection.

GET

/api/files/

Returns list of all available log files and metadata.

GET

/api/export/

Exports filtered logs as a downloadable JSON or CSV file.

Running Tests

To run the test suite:

python3 runtests.py

License

Released under the MIT License.

Metadata

Release files for django-simple-log-viewer 2.0.0

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

Source distribution (sdist)

Source distribution for django-simple-log-viewer 2.0.0
File Size Uploaded Provenance Actions
django_simple_log_viewer-2.0.0.tar.gz 304.4 kB Without provenance Details for django_simple_log_viewer-2.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for django-simple-log-viewer 2.0.0
File Interpreter ABI Platform Actions
django_simple_log_viewer-2.0.0-py3-none-any.whl Python 3 none any Details for django_simple_log_viewer-2.0.0-py3-none-any.whl

Total release size: 616.4 kB

Release files / django_simple_log_viewer-2.0.0.tar.gz

Download URL django_simple_log_viewer-2.0.0.tar.gz
Size 304.4 kB
Tags Source
SHA-256 checksum
How to use checksums
e564ede36a42bb7e13bfa4b742d095fbb95f4dbe7f03d66e52bb5fe11b203f0e
BLAKE2b-256 checksum
How to use checksums
1594a2f3b2355e82493d37e00cb229d109e30edf1931a33a16315838fabc04f1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.5.0 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.13

Release files / django_simple_log_viewer-2.0.0-py3-none-any.whl

Download URL django_simple_log_viewer-2.0.0-py3-none-any.whl
Size 312.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8505afd495b96fe6913d9e70b407cf069bffa16bd243b9f47c3e785a087749a3
BLAKE2b-256 checksum
How to use checksums
3ff29bb43784f817484e2865121deeec7099f46759b1e916a922cc43c98aa0a2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.5.0 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.13

Security for django-simple-log-viewer 2.0.0

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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