Created
November 1, 2011 19:34
-
-
Save tswicegood/1331656 to your computer and use it in GitHub Desktop.
Simple code to hook up Celery and Loggly
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
LOGGLY_INPUT_KEY = "your key here" | |
import hoover | |
import logging | |
def initialize_loggly(loglevel=logging.WARN, **kwargs): | |
handler = hoover.LogglyHttpHandler(token=LOGGLY_INPUT_KEY) | |
log = logging.getLogger('celery') | |
log.addHandler(handler) | |
log.setLevel(loglevel) | |
return log | |
from celery.signals import setup_logging | |
setup_logging.connect(initialize_loggly) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
thanks. I modified it a little bit just in case
in your celeryconfig.py add at the bottom:
and your logly-celery.conf is something like:
replace YOURTOKENHERE and YOURTAGHERE
where YOURTAGHERE is the name of tag you want to mark all celery "log entries" inside logly
[handlers]
keys=HTTPSHandler
[handler_HTTPSHandler]
class=loggly.handlers.HTTPSHandler
args=('https://logs-01.loggly.com/inputs/YOURTOKENHERE/tag/YOURTAGHERE','POST')
[formatters]
keys=
[loggers]
keys=root
[logger_root]
handlers=HTTPSHandler
level=INFO
if you run your celery worker and it crashes with message like 'no formatters found' it means - you put your celery-logly.conf in a place that celery worker doesn't see.