相关疑难解决方法(0)

将日志添加到Airflow日志

如何将自己的日志添加到自动生成的Apache Airflow日志中?任何打印语句都不会登录,所以我想知道如何添加我的日志,以便它也显示在用户界面上?

apache logging etl python-3.x airflow

12
推荐指数
2
解决办法
8478
查看次数

Airflow + python 日志记录模块不写入日志文件

尝试将“hello world”写入气流日志(气流 1.10.3)。基于此处此处介绍的 SO 解决方案,我应该能够import logginglogging.info('hello world')。这对我来说似乎不起作用。

import logging
from datetime import datetime, timedelta
from airflow import DAG
from airflow.operators.python_operator import PythonOperator

default_args = {
    'owner': 'benten',
    'depends_on_past': False,
    'start_date': datetime(2019, 7, 25),
    'email_on_failure': False,
    'retries': 1,
    'retry_delay': timedelta(minutes=1),
    }

def logging_is_fun():
    logging.debug("hellow world")
    logging.info("hello world")
    logging.critical("hello world")
    return None

with DAG('fun_logs', schedule_interval='45 * * * *', default_args=default_args) as dag:
    log_task = PythonOperator(python_callable=logging_is_fun, task_id='log_test_task')
Run Code Online (Sandbox Code Playgroud)

我手动触发了 dag,任务执行没有问题。但唉,当我检查日志时,我看到的是:

*** Reading local file: /home/ubuntu/airflow/logs/fun_logs/log_test_task/2019-08-31T19:22:49.653712+00:00/1.log

我惊人的“hello …

python logging airflow

9
推荐指数
1
解决办法
4796
查看次数

标签 统计

airflow ×2

logging ×2

apache ×1

etl ×1

python ×1

python-3.x ×1