Allows download django log file via api
- django >= 2.2
- djangorestframework >= 3.9.2
- tailhead
- Install package
pip install django-log-api
# or
poetry add django-log-api
- Add to the INSTALLED_APPS
settings.py
INSTALLED_APPS = [
...,
"log_api",
]
# log dir path, use Path(), default: BASE_DIR / logs
LOG_API_DIR_PATH = BASE_DIR / "logs"
# log file name, default: 'django.log'
LOG_API_DEFAULT_FILE = "django.log"
# log tail numbers, default: 1000
LOG_API_MAX_READ_LINES = 1000
# log api permission, use drf`s permission, default: AllowAny
LOG_API_PERMISSION_CLASSES = ("rest_framework.permissions.AllowAny",)
- add to urls.py
path(r"logs/", include("log_api.urls")),
parameters:
- name: log file name
- tail: if null, download entire log file, others the tail lines number