jelko / django-log-viewer

Django Log Viewer allows you to read & download log files in the admin page

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Django Log Viewer

pypi version license build status

Django Log Viewer allows you to read & download log files in the admin page by using DataTables. This project was modified from: https://bitbucket.org/inkalabsinc/django-log-viewer


https://i.imgur.com/IZQKm4T.png

Quick start

  1. Django Log Viewer is available directly from PyPI:
pip install django-log-viewer
  1. Add "log_viewer" to your INSTALLED_APPS setting like this
INSTALLED_APPS = [
    ...
    "log_viewer",
]
  1. Include the log viewer URLconf in your project urls.py like this
path('admin/log_viewer/', include('log_viewer.urls')),
  1. In your settings.py file create the following value
LOG_VIEWER_FILES = ['logfile1', 'logfile2', ...]
LOG_VIEWER_FILES_PATTERN = 'logfile*'
LOG_VIEWER_FILES_DIR = os.path.join(BASE_DIR, '../logs')
LOG_VIEWER_MAX_READ_LINES = 1000  # total log lines will be read
LOG_VIEWER_PAGE_LENGTH = 25       # total log lines per-page
LOG_VIEWER_PATTERNS = [']OFNI[', ']GUBED[', ']GNINRAW[', ']RORRE[', ']LACITIRC[']

# Optionally you can set the next variables in order to customize the admin:

LOG_VIEWER_FILE_LIST_TITLE = "Custom title"
LOG_VIEWER_FILE_LIST_STYLES = "/static/css/my-custom.css"
  1. Create/register the logging
import logging
logger = logging.getLogger('LoggerName')
logger.info('The info message')
logger.warning('The warning message')
logger.error('The error message')
  1. Deploy static files by running the command
python manage.py collectstatic
  1. Start the development server and visit http://127.0.0.1:8000/admin/log_viewer/

About

Django Log Viewer allows you to read & download log files in the admin page

License:MIT License


Languages

Language:JavaScript 47.7%Language:CSS 38.8%Language:Python 10.7%Language:HTML 2.7%Language:Shell 0.1%