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_level #21506

Merged
merged 1 commit into from
Feb 19, 2022
Merged
Show file tree
Hide file tree
Changes from all 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
6 changes: 5 additions & 1 deletion airflow/cli/commands/celery_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,10 @@ def worker(args):
# it, we raced to create the tables and lost.
pass

# backwards-compatible: https://github.com/apache/airflow/pull/21506#pullrequestreview-879893763
celery_log_level = conf.get('logging', 'CELERY_LOGGING_LEVEL')
if not celery_log_level:
celery_log_level = conf.get('logging', 'LOGGING_LEVEL')
# Setup Celery worker
options = [
'worker',
Expand All @@ -146,7 +150,7 @@ def worker(args):
'--hostname',
args.celery_hostname,
'--loglevel',
conf.get('logging', 'LOGGING_LEVEL'),
celery_log_level,
'--pidfile',
pid_file_path,
]
Expand Down
9 changes: 9 additions & 0 deletions airflow/config_templates/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,15 @@
type: string
example: ~
default: "INFO"
- name: celery_logging_level
description: |
Logging level for celery. If not set, it uses the value of logging_level

Supported values: ``CRITICAL``, ``ERROR``, ``WARNING``, ``INFO``, ``DEBUG``.
version_added: 2.3.0
type: string
example: ~
default: ""
- name: fab_logging_level
description: |
Logging level for Flask-appbuilder UI.
Expand Down
5 changes: 5 additions & 0 deletions airflow/config_templates/default_airflow.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,11 @@ encrypt_s3_logs = False
# Supported values: ``CRITICAL``, ``ERROR``, ``WARNING``, ``INFO``, ``DEBUG``.
logging_level = INFO

# Logging level for celery. If not set, it uses the value of logging_level
#
# Supported values: ``CRITICAL``, ``ERROR``, ``WARNING``, ``INFO``, ``DEBUG``.
celery_logging_level =

# Logging level for Flask-appbuilder UI.
#
# Supported values: ``CRITICAL``, ``ERROR``, ``WARNING``, ``INFO``, ``DEBUG``.
Expand Down
1 change: 1 addition & 0 deletions airflow/config_templates/default_test.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ store_serialized_dags = False
[logging]
base_log_folder = {AIRFLOW_HOME}/logs
logging_level = INFO
celery_logging_level = WARN
fab_logging_level = WARN
log_filename_template = {{{{ ti.dag_id }}}}/{{{{ ti.task_id }}}}/{{{{ ts }}}}/{{{{ try_number }}}}.log
log_processor_filename_template = {{{{ filename }}}}.log
Expand Down
2 changes: 2 additions & 0 deletions airflow/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,8 @@ class AirflowConfigParser(ConfigParser):
("scheduler", "file_parsing_sort_mode"): ["modified_time", "random_seeded_by_host", "alphabetical"],
("logging", "logging_level"): _available_logging_levels,
("logging", "fab_logging_level"): _available_logging_levels,
# celery_logging_level can be empty, which uses logging_level as fallback
("logging", "celery_logging_level"): _available_logging_levels + [''],
}

# This method transforms option names on every read, get, or set operation.
Expand Down
2 changes: 1 addition & 1 deletion tests/cli/commands/test_celery_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ def test_worker_started_with_required_arguments(self, mock_celery_app, mock_pope
'--hostname',
celery_hostname,
'--loglevel',
conf.get('logging', 'LOGGING_LEVEL'),
conf.get('logging', 'CELERY_LOGGING_LEVEL'),
'--pidfile',
pid_file,
'--autoscale',
Expand Down