### Apache Airflow version 2.2.2 (latest released) ### What happened * (1). When I set airflow.cfg with: default_ui_timezone = Asia/Shanghai default_timezone = Asia/Shanghai * (2). start weserver and scheduler * (3). trigger "example_bash_operator" task manually * (4). in upper right corner select ui display timezone with "CST +(08:00)" * (5). I find task log time in web page is wrong, it faster 8 hours than it real is. ### What you expected to happen * In web page it shdould display the correct log time. ### How to reproduce * As described In "What happened". * I think this is cause by the logger use localtime but not UTC. Why should we save all time with UTC in database but localtime in log? ### Operating System Ubuntu 20 ### Versions of Apache Airflow Providers apache-airflow-providers-ftp==2.0.1 apache-airflow-providers-http==2.0.1 apache-airflow-providers-imap==2.0.1 apache-airflow-providers-sqlite==2.0.1 ### Deployment Other ### Deployment details pip freeze | grep apache-airflow-providers ### Anything else I think it's can be fixed by add a UTCFromatter for logger. edit file "airflow/airflow/config_templates/airflow_local_settings.py" ``` python +import logging +import time + +class UTCFormatter(logging.Formatter): + converter = time.gmtime + DEFAULT_LOGGING_CONFIG: Dict[str, Any] = { 'version': 1, 'disable_existing_loggers': False, 'formatters': { - 'airflow': {'format': LOG_FORMAT}, + 'airflow': {'()': UTCFormatter, 'format': LOG_FORMAT}, ``` ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)
Activity
boring-cyborg commentedon Dec 15, 2021
Thanks for opening your first issue here! Be sure to follow the issue template!
uranusjr commentedon Dec 15, 2021
Aleady fixed in #19401.
xmduhan commentedon Dec 16, 2021
@uranusjr
I try changes on : https://github.com/apache/airflow/pull/19401/files, But it doesn't work for me.