xmduhan opened a new issue #20315:
URL: https://github.com/apache/airflow/issues/20315


   ### 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)
   


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