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

🔊 add celery logging #87

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions open_api_framework/conf/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,13 @@
RuntimeWarning,
)

CELERY_LOGLEVEL = config(
"CELERY_LOGLEVEL",
default="INFO",
help_text="control the verbosity of logging output for celery, separate from ``LOG_LEVEL``."
" Available values are ``CRITICAL``, ``ERROR``, ``WARNING``, ``INFO`` and ``DEBUG``",
)

LOGGING_DIR = Path(BASE_DIR) / "log"

logging_root_handlers = ["console"] if LOG_STDOUT else ["project"]
Expand Down Expand Up @@ -415,6 +422,19 @@
"class": "logging.StreamHandler",
"formatter": "db",
},
"console_celery": {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A note to rename one or the other

"level": CELERY_LOGLEVEL,
"class": "logging.StreamHandler",
"formatter": "timestamped",
},
"celery_file": {
"level": CELERY_LOGLEVEL,
"class": "logging.handlers.RotatingFileHandler",
"filename": Path(LOGGING_DIR) / "celery.log",
"formatter": "verbose",
"maxBytes": 1024 * 1024 * 10, # 10 MB
"backupCount": 10,
},
"django": {
"level": LOG_LEVEL,
"class": "logging.handlers.RotatingFileHandler",
Expand Down Expand Up @@ -507,6 +527,11 @@
"level": "DEBUG",
"propagate": True,
},
"celery": {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While this will add the logs of the celery library itself, does the logging that happens inside celery tasks still work as well? Because from Sjoerd's issue I see that there is no logging at all. The regular logging is picked up by the project handler i think, even if it happens inside the celery worker

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does appearing in Celery yes

Screenshot from 2024-11-29 15-17-21

Also with just INFO

Screenshot from 2024-11-29 15-16-35

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does need LOG_STDOUT to be enabled though

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check, I think it's fine to accept these changes then. I do think that the logs no longer showing has to do with either LOG_STDOUT or LOG_LEVEL, so I've asked Sjoerd to see what the values of those are open-zaak/open-zaak#1802 (comment)

"handlers": ["console_celery"] if LOG_STDOUT else ["celery_file"],
"level": CELERY_LOGLEVEL,
"propagate": True,
},
},
}

Expand Down
Loading