Graylog middleware for Django.
Project description
django-graylog
A Django middleware for logging requests to Graylog.
Installation
pip install django-graylog
Configuration
Simply add django_graylog.GraylogMiddleware
to your MIDDLEWARE
setting, after
django.middleware.common.CommonMiddleware
. By default, the middleware does nothing unless GRAYLOG_ENDPOINT
is set
(see below).
Settings
GRAYLOG_ENDPOINT
- An HTTP/HTTPS/UDP endpoint to send GELF logs to. For example,http://yourserver:12201/gelf
orudp://yourserver:12201
.GRAYLOG_NODE
- The middleware sends a_node
field that defaults tosocket.gethostname
. Set this to override it.GRAYLOG_LEVEL
- The defaultlevel
to send for log entries. Defaults to 6 (INFO).GRAYLOG_TIMEOUT
- Timeout for sending log entries to Graylog. Defaults to0.25
seconds.GRAYLOG_FIELDS
- Extra fields to send for each request (not prefixed with underscores). Defaults to{}
.
Advanced Usage
In addition to the standard logging middleware, django_graylog
installs an object on your request objects
(request.graylog
) that has standard logging methods for recording per-request logs. You may also set custom keys on
this object (request.graylog["key"] = "value"
) that will be included in log entries. For example:
def homepage(request):
request.graylog["user"] = request.user.user_name
request.graylog.info("Rendered the homepage for {user}", user=request.user.user_name)
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Hashes for django_graylog-0.3.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6910b86e93226d6f459014356d90a9e7b61d6007e7d16009bab93ac1d75e1862 |
|
MD5 | be761369eb47f72196938fd7379f1e64 |
|
BLAKE2b-256 | f3abbd47fe5aac77daf42d7c9b45d4371810d8a38ce84d6c2066966399723ce7 |