-
Notifications
You must be signed in to change notification settings - Fork 14.5k
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
Webserver shows wrong datetime (timezone) in log #23796
Comments
Thanks for opening your first issue here! Be sure to follow the issue template! |
Just to document the history: This was initially fixed in #19401 and then reverted in #23075 For some users the logs are in the server time and for others the logs are in UTC. Also a side note - I think #19401 was a partial fix as it does not take in account that the offset for a timezone can change. |
It sounds like a configuration is the only way to satisfy all use cases. There’s no way Airflow can automatically know what timezone the log files use otherwise. |
I found workaround. via configuration. here's how:
import logging
import time
from copy import deepcopy
from airflow.config_templates.airflow_local_settings import DEFAULT_LOGGING_CONFIG
LOGGING_CONFIG = deepcopy(DEFAULT_LOGGING_CONFIG)
# from https://stackoverflow.com/a/60342048
class UTCFormatter(logging.Formatter):
converter = time.gmtime # this makes logger's asctime as UTC
LOGGING_CONFIG['formatters']['airflow']['class'] = 'airflow_local_settings.UTCFormatter'
[logging]
logging_config_class = airflow_local_settings.LOGGING_CONFIG
I have tried something like |
@uranusjr |
I never waid assuming UTC is right, but the problem is the frontend doesn’t know what timezone the log files used. Appending |
@uranusjr Seems to need more explain about PR, let me supplement that. In the comment above, I found a way to do it only with configuration, so I used While writing PR , I was also able to edit the UI regex, so I didn't have to lock the log to UTC, so I didn't use Instead, I override the Thankfully Since we are already using
all I have to do is pass in a datetime string that |
Apache Airflow version
2.3.0 (latest released)
What happened
same as #19401 , when I open task`s log in web interface, it shifts this time forward by 8 hours (for Asia/Shanghai), but it's already in Asia/Shanghai.
here is the log in web:
As you seee, UTC time is 2022-05-18T09:50:00,and My timezone is Asia/Shanghai(should shift forward 8 hours),but it shift forward 16hours!
What you think should happen instead
No response
How to reproduce
No response
Operating System
Debian GNU/Linux 11 (bullseye)(docker)
Versions of Apache Airflow Providers
No response
Deployment
Docker-Compose
Deployment details
use my image to run airflow by docker-compose
check task logs in web
Although I have changed the file
airflow/www/static/js/ti_log.js
, but it did not work! Then check source from Web, I found another file :airflow/www/static/dist/tiLog.e915520196109d459cf8.js
, then I replace "+00:00" by "+08:00" in this file. Finally it works!Anything else
No response
Are you willing to submit PR?
Code of Conduct
The text was updated successfully, but these errors were encountered: