Writing to Airflow Logs

后端 未结 2 433
伪装坚强ぢ
伪装坚强ぢ 2020-12-14 06:29

One way to write to the logs in Airflow is to return a string from a PythonOperator like on line 44 here.

Are there other ways that allow me to write to the airflow

相关标签:
2条回答
  • 2020-12-14 06:45

    You can import the logging module into your code and write to logs that way

    import logging
    
    logging.info('Hello')
    

    Here are some more options

    import logging    
    
    logging.debug('This is a debug message')
    logging.info('This is an info message')
    logging.warning('This is a warning message')
    logging.error('This is an error message')
    logging.critical('This is a critical message')
    
    0 讨论(0)
  • 2020-12-14 07:07

    You might use airflow logger

    import logging
    
    
    logger = logging.getLogger("airflow.task")
    logger.error("Your custom error")
    
    0 讨论(0)
提交回复
热议问题