nailo2c opened a new pull request, #61701:
URL: https://github.com/apache/airflow/pull/61701

   related: #49966
   
   # Why
   
   When setting `AIRFLOW__LOGGING__CELERY_STDOUT_STDERR_SEPARATION=True`, it 
will use `DEFAULT_TASK_LOG_FMT` as the log format.
   
   
https://github.com/apache/airflow/blob/1aaa87bc624f30cdd487874537d8039a97c2f95a/providers/celery/src/airflow/providers/celery/cli/celery_command.py#L168-L169
   
   <br>
   
   However, `DEFAULT_TASK_LOG_FMT` contains `task_name` and `task_id` which are 
not handled by the default `logging.Formatter`.
   
   ```python
   >>> from celery.app.defaults import DEFAULT_TASK_LOG_FMT
   >>> print(DEFAULT_TASK_LOG_FMT)
   [%(asctime)s: %(levelname)s/%(processName)s] %(task_name)s[%(task_id)s]: 
%(message)s
   ```
   
   # How
   
   Use `TaskFormatter` from **Celery** to handle `task_name` and `task_id`.
   
   Ref: https://github.com/celery/celery/blob/main/celery/app/log.py#L41-L42
   
   # What
   
   Set `AIRFLOW__LOGGING__CELERY_STDOUT_STDERR_SEPARATION=True`.
   Then start Airflow with: `breeze start-airflow --executor CeleryExecutor 
--integration celery`.
   
   + Before fix
   <img width="1453" height="873" alt="49966_before_fixed" 
src="https://github.com/user-attachments/assets/22a554ba-d14c-4470-b2a7-ba2353a7a233";
 />
   
   + After fix
   <img width="1456" height="642" alt="49966_after_fixed" 
src="https://github.com/user-attachments/assets/36511193-8b1c-4e51-b43c-ec4662684ff9";
 />
   
   ---
   
   ##### Was generative AI tooling used to co-author this PR?
   
   <!--
   If generative AI tooling has been used in the process of authoring this PR, 
please
   change below checkbox to `[X]` followed by the name of the tool, uncomment 
the "Generated-by".
   -->
   
   - [ ] No (please specify the tool below)
   
   <!--
   Generated-by: [Tool Name] following [the 
guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions)
   -->
   
   ---
   
   * Read the **[Pull Request 
Guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#pull-request-guidelines)**
 for more information. Note: commit author/co-author name and email in commits 
become permanently public when merged.
   * For fundamental code changes, an Airflow Improvement Proposal 
([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvement+Proposals))
 is needed.
   * When adding dependency, check compliance with the [ASF 3rd Party License 
Policy](https://www.apache.org/legal/resolved.html#category-x).
   * For significant user-facing changes create newsfragment: 
`{pr_number}.significant.rst` or `{issue_number}.significant.rst`, in 
[airflow-core/newsfragments](https://github.com/apache/airflow/tree/main/airflow-core/newsfragments).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to