Stop New Relic / Celery From Polluting Logs on Heroku
Question: # Question

How can you stop New Relic / Celery from constantly printing the below to
Heroku's log.

    
    
    app[scheduler.1]: [INFO/MainProcess] Starting new HTTP connection (1): collector-6.newrelic.com
    app[scheduler.1]: [INFO/MainProcess] Starting new HTTP connection (1): collector-6.newrelic.com
    app[scheduler.1]: [INFO/MainProcess] Starting new HTTP connection (1): collector-6.newrelic.com
    app[scheduler.1]: [INFO/MainProcess] Starting new HTTP connection (1): collector-6.newrelic.com
    

## Setup

The above log entries appear every minute. The app reporting this is a celery
worker started via `Procfile` that reads (in part):

    
    
    scheduler: newrelic-admin run-program python manage.py celery worker --loglevel=ERROR -B -E --maxtasksperchild=1000
    

Despite setting `loglevel` to `ERROR` it appears that celery is ignoring this
argument. Interestingly enough, on my local machine, this setting is
respected.

### Versions

    
    
    celery==3.0.12
    django-celery==3.0.11
    newrelic==1.6.0.13
    


Answer: Temporary solution, per New Relic support, is to add the below to your
settings.py or a celeryconfig.py (depending on which you use for celery
settings).

    
    
    import logging
    class RequestsConnectionFilter(logging.Filter):
        def filter(self, record):
            return False
    logging.getLogger('newrelic.lib.requests.packages.urllib3.connectionpool').addFilter(RequestsConnectionFilter())
    

NR support told me they plan to build this suppression into future versions of
the python agent.

