Skip to content

Instantly share code, notes, and snippets.

@joar
Created November 2, 2017 15:11
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joar/868e440b30bf619f5aee7d737fb5a660 to your computer and use it in GitHub Desktop.
Save joar/868e440b30bf619f5aee7d737fb5a660 to your computer and use it in GitHub Desktop.
gunicorn - disable logging configuration
import gunicorn.glogging
import structlog
_logger = structlog.get_logger(__name__)
class Logger(gunicorn.glogging.Logger):
def setup(self, cfg):
"""
Attempts to override gunicorn's logging configuration entirely
"""
_logger.warning('gunicorn-logging-override')
# Override gunicorns false start at logging configuration in __init__()
self.access_log.propagate = True
self.error_log.propagate = True
return
# You **NEED** this file in order to get gunicorn to be able to load te module containing your logger.
from setuptools import setup, find_packages
setup(
name='gunicorn_logging',
version='0.1.0-dev',
packages=find_packages(),
entry_points={
'gunicorn.loggers': [
'gunicorn_logging.Logger = gunicorn_logging.Logger'
]
}
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment