Logging

accesslog

  • --access-logfile FILE
  • None

The Access log file to write to.

'-' means log to stdout.

disable_redirect_access_to_syslog

  • --disable-redirect-access-to-syslog
  • False

Disable redirect access logs to syslog.

New in version 19.8.

access_log_format

  • --access-logformat STRING
  • %(h)s %(l)s %(u)s %(t)s "%(r)s" %(s)s %(b)s "%(f)s" "%(a)s"

The access log format.

IdentifierDescription
hremote address
l‘-‘
uuser name
tdate of the request
rstatus line (e.g. GET / HTTP/1.1)
mrequest method
UURL path without query string
qquery string
Hprotocol
sstatus
Bresponse length
bresponse length or ‘-‘ (CLF format)
freferer
auser agent
Trequest time in seconds
Drequest time in microseconds
Lrequest time in decimal seconds
pprocess ID
{header}irequest header
{header}oresponse header
{variable}eenvironment variable

Use lowercase for header and environment variable names, and put {...}x names inside %(...)s. For example:

  1. %({x-forwarded-for}i)s

errorlog

  • --error-logfile FILE, --log-file FILE
  • -

The Error log file to write to.

Using '-' for FILE makes gunicorn log to stderr.

Changed in version 19.2: Log to stderr by default.

loglevel

  • --log-level LEVEL
  • info

The granularity of Error log outputs.

Valid level names are:

  • debug
  • info
  • warning
  • error
  • critical

capture_output

  • --capture-output
  • False

Redirect stdout/stderr to specified file in errorlog.

New in version 19.6.

logger_class

  • --logger-class STRING
  • gunicorn.glogging.Logger

The logger you want to use to log events in Gunicorn.

The default class (gunicorn.glogging.Logger) handle most of normal usages in logging. It provides error and access logging.

You can provide your own logger by giving Gunicorn a Python path to a subclass like gunicorn.glogging.Logger.

logconfig

  • --log-config FILE
  • None

The log config file to use. Gunicorn uses the standard Python logging module’s Configuration file format.

logconfig_dict

  • --log-config-dict
  • {}

The log config dictionary to use, using the standard Python logging module’s dictionary configuration format. This option takes precedence over the logconfig option, which uses the older file configuration format.

Format: https://docs.python.org/3/library/logging.config.html#logging.config.dictConfig

New in version 19.8.

syslog_addr

  • --log-syslog-to SYSLOG_ADDR
  • udp://localhost:514

Address to send syslog messages.

Address is a string of the form:

  • unix://PATH#TYPE : for unix domain socket. TYPE can be stream for the stream driver or dgram for the dgram driver. stream is the default.
  • udp://HOST:PORT : for UDP sockets
  • tcp://HOST:PORT : for TCP sockets

syslog

  • --log-syslog
  • False

Send Gunicorn logs to syslog.

Changed in version 19.8: You can now disable sending access logs by using the disable_redirect_access_to_syslog setting.

syslog_prefix

  • --log-syslog-prefix SYSLOG_PREFIX
  • None

Makes Gunicorn use the parameter as program-name in the syslog entries.

All entries will be prefixed by gunicorn.<prefix>. By default the program name is the name of the process.

syslog_facility

  • --log-syslog-facility SYSLOG_FACILITY
  • user

Syslog facility name

enable_stdio_inheritance

  • -R, --enable-stdio-inheritance
  • False

Enable stdio inheritance.

Enable inheritance for stdio file descriptors in daemon mode.

Note: To disable the Python stdout buffering, you can to set the user environment variable PYTHONUNBUFFERED .

statsd_host

  • --statsd-host STATSD_ADDR
  • None

host:port of the statsd server to log to.

New in version 19.1.

dogstatsd_tags

  • --dogstatsd-tags DOGSTATSD_TAGS
  • (empty string)

A comma-delimited list of datadog statsd (dogstatsd) tags to append to statsd metrics.

New in version 20.

statsd_prefix

  • --statsd-prefix STATSD_PREFIX
  • (empty string)

Prefix to use when emitting statsd metrics (a trailing . is added, if not provided).

New in version 19.2.