* refactor: always use console log handler * refactor: json for k8s, plain otherwise * chore: remove syslog from wsgi.py * chore: remove debug.log() * chore: drop syslog from settings.py * refactor: use log.log() in person.utils * refactor: fetch_meeting_attendance->log.log() * chore: gunicorn logs as JSON (wip) * feat: better json log formatting * refactor: improve log config * feat: gunicorn access log fields * fix: remove type hints The gunicorn logger plays tricks with the LogRecord args parameter to let it have string keys instead of being a simple tuple. The mypy tests rightly flag this. Rather than fighting the typing, just remove the hints and leave a comment warning not to use the gunicorn-specific formatter with other loggers.
50 lines
1.5 KiB
Python
50 lines
1.5 KiB
Python
# Copyright The IETF Trust 2024, All Rights Reserved
|
|
|
|
# Log as JSON on stdout (to distinguish from Django's logs on stderr)
|
|
#
|
|
# This is applied as an update to gunicorn's glogging.CONFIG_DEFAULTS.
|
|
logconfig_dict = {
|
|
"version": 1,
|
|
"disable_existing_loggers": False,
|
|
"root": {"level": "INFO", "handlers": ["console"]},
|
|
"loggers": {
|
|
"gunicorn.error": {
|
|
"level": "INFO",
|
|
"handlers": ["console"],
|
|
"propagate": False,
|
|
"qualname": "gunicorn.error"
|
|
},
|
|
|
|
"gunicorn.access": {
|
|
"level": "INFO",
|
|
"handlers": ["access_console"],
|
|
"propagate": False,
|
|
"qualname": "gunicorn.access"
|
|
}
|
|
},
|
|
"handlers": {
|
|
"console": {
|
|
"class": "logging.StreamHandler",
|
|
"formatter": "json",
|
|
"stream": "ext://sys.stdout"
|
|
},
|
|
"access_console": {
|
|
"class": "logging.StreamHandler",
|
|
"formatter": "access_json",
|
|
"stream": "ext://sys.stdout"
|
|
},
|
|
},
|
|
"formatters": {
|
|
"json": {
|
|
"class": "ietf.utils.jsonlogger.DatatrackerJsonFormatter",
|
|
"style": "{",
|
|
"format": "{asctime}{levelname}{message}{name}{process}",
|
|
},
|
|
"access_json": {
|
|
"class": "ietf.utils.jsonlogger.GunicornRequestJsonFormatter",
|
|
"style": "{",
|
|
"format": "{asctime}{levelname}{message}{name}{process}",
|
|
}
|
|
}
|
|
}
|