写入气流日志 [英] Writing to Airflow Logs

查看:57
本文介绍了写入气流日志的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

写到Airflow中日志的一种方法是从PythonOperator返回一个字符串,如第44行此处

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 log files? I've found that print statements are not saved to the logs.

推荐答案

您可以将日志记录模块导入代码并编写以这种方式记录

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

import logging

logging.info('Hello')

还有更多选择

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

这篇关于写入气流日志的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆