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

Maybe should write log use UTC time. #20315

Closed
2 tasks done
xmduhan opened this issue Dec 15, 2021 · 3 comments
Closed
2 tasks done

Maybe should write log use UTC time. #20315

xmduhan opened this issue Dec 15, 2021 · 3 comments
Labels
area:core duplicate Issue that is duplicated kind:bug This is a clearly a bug

Comments

@xmduhan
Copy link

xmduhan commented Dec 15, 2021

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"

+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?

  • Yes I am willing to submit a PR!

Code of Conduct

@xmduhan xmduhan added area:core kind:bug This is a clearly a bug labels Dec 15, 2021
@boring-cyborg
Copy link

boring-cyborg bot commented Dec 15, 2021

Thanks for opening your first issue here! Be sure to follow the issue template!

@uranusjr
Copy link
Member

uranusjr commented Dec 15, 2021

Aleady fixed in #19401.

@uranusjr uranusjr added the duplicate Issue that is duplicated label Dec 15, 2021
@xmduhan
Copy link
Author

xmduhan commented Dec 16, 2021

@uranusjr
I try changes on : https://github.com/apache/airflow/pull/19401/files, But it doesn't work for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:core duplicate Issue that is duplicated kind:bug This is a clearly a bug
Projects
None yet
Development

No branches or pull requests

2 participants