diff --git a/README.rst b/README.rst index 1085feff..9e935f68 100644 --- a/README.rst +++ b/README.rst @@ -154,7 +154,7 @@ statsD consumer. To use this instrumentation mechanism, simply use a new logger:: - $ gunicorn --logging-class gunicorn.instrument.statsd.Statsd ... + $ gunicorn --statsd-to localhost:8125 ... The `Statsd` logger overrides `gunicorn.glogging.Logger` to track all requests. The following metrics are generated: diff --git a/gunicorn/config.py b/gunicorn/config.py index ba6116ac..c6dbdbfe 100644 --- a/gunicorn/config.py +++ b/gunicorn/config.py @@ -142,8 +142,13 @@ class Config(object): if uri == "simple": # support the default uri = "gunicorn.glogging.Logger" - - logger_class = util.load_class(uri, + + # if statsd is on, automagically switch to the statsd logger + if 'statsd_to' in self.settings: + logger_class = util.load_class("gunicorn.instrument.statsd.Statsd", + section="gunicorn.loggers") + else: + logger_class = util.load_class(uri, default="gunicorn.glogging.Logger", section="gunicorn.loggers") @@ -1639,7 +1644,7 @@ if sys.version_info >= (2, 7): class StatsdTo(Setting): name = "statsd_to" section = "Logging" - cli = ["--log-statsd-to"] + cli = ["--statsd-to"] meta = "STATSD_ADDR" default = "localhost:8125" validator = validate_hostport diff --git a/tests/test_009-statsd.py b/tests/test_010-statsd.py similarity index 100% rename from tests/test_009-statsd.py rename to tests/test_010-statsd.py