Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Celery logging #8

Open
p1nox opened this issue Jun 9, 2017 · 0 comments
Open

Celery logging #8

p1nox opened this issue Jun 9, 2017 · 0 comments

Comments

@p1nox
Copy link

p1nox commented Jun 9, 2017

Is there a special way of using logmatic on celery workers? I can't get the logger to write into output files, I see the output files are created, but despite the worker runs without a problem, no logs are appended into the files.

This is my current logger setup:

import logging
import logging.config
import logmatic

from config import config 

DEFAULT_LOGGER_FORMAT = "%(timestamp) %(message) %(filename) %(funcName) %(levelname) %(lineno)"
DEFAULT_EXTRA_ATTRIBUTES = {
    "version": config.APP_VERSION
}

# disable default global info logs
logging.getLogger("requests").setLevel(logging.WARNING)

global_logger = logging.getLogger()
json_formatter = logmatic.JsonFormatter(fmt=DEFAULT_LOGGER_FORMAT, extra=DEFAULT_EXTRA_ATTRIBUTES)

info_file_handler = logging.FileHandler(config.INFO_LOGFILE_PATH)
info_file_handler.setFormatter(json_formatter)
info_file_handler.setLevel(logging.INFO)
global_logger.addHandler(info_file_handler)

debug_file_handler = logging.FileHandler(config.DEBUG_LOGFILE_PATH)
debug_file_handler.setFormatter(json_formatter)
debug_file_handler.setLevel(logging.DEBUG)
global_logger.addHandler(debug_file_handler)

stream_handler = logging.StreamHandler()
stream_handler.setFormatter(json_formatter)
stream_handler.setLevel(logging.INFO)
global_logger.addHandler(stream_handler)

global_logger.setLevel(logging.INFO)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant