Skip to main content

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 endpoint to send GELF logs to. For example, http://yourserver:12201/gelf.
  • GRAYLOG_NODE - The middleware sends a _node field that defaults to socket.gethostname. Set this to override it.
  • GRAYLOG_LEVEL - The default level to send for log entries. Defaults to 6 (INFO).
  • GRAYLOG_TIMEOUT - Timeout for sending log entries to Graylog. Defaults to 0.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

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

django_graylog-0.2.1-py3-none-any.whl (3.8 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page