I've since found that whilst setting 'console' as a handler for the airflow.task logger allows you to see the output of 'airflow test' commands, it also seems to cause 'airflow run' commands to enter an infinite loop and run out of memory. I would therefore only do this in an environment where you only want to run 'airflow test' commands
Why it does this I don't know yet, and whether there's a way to accomplish this question without breaking 'airflow run' is unclear to me
The default logging config for Airflow 1.10.0 has the following loggers available:
'loggers': {
'airflow.processor': {
'handlers': ['processor'],
'level': LOG_LEVEL,
'propagate': False,
},
'airflow.task': {
'handlers': ['task'],
'level': LOG_LEVEL,
'propagate': False,
},
'flask_appbuilder': {
'handler': ['console'],
'level': FAB_LOG_LEVEL,
'propagate': True,
}
},
and the airflow.task logger (which is the logger used when running your task) uses the 'task' handler:
'handlers': {
'console': {
'class': 'airflow.utils.log.logging_mixin.RedirectStdHandler',
'formatter': 'airflow',
'stream': 'sys.stdout'
},
'task': {
'class': 'airflow.utils.log.file_task_handler.FileTaskHandler',
'formatter': 'airflow',
'base_log_folder': os.path.expanduser(BASE_LOG_FOLDER),
'filename_template': FILENAME_TEMPLATE,
},
'processor': {
'class': 'airflow.utils.log.file_processor_handler.FileProcessorHandler',
'formatter': 'airflow',
'base_log_folder': os.path.expanduser(PROCESSOR_LOG_FOLDER),
'filename_template': PROCESSOR_FILENAME_TEMPLATE,
},
},
which (unless changed) will only write the output of the task to a log file. If you want to see the output in stdout as well, then you need add the console handler to the list of handlers used by the airflow.task logger:
'airflow.task': {
'handlers': ['task', 'console'],
'level': LOG_LEVEL,
'propagate': False,
},
This can be done by either setting up a custom logging configuration class, which overrides the default configuration, or by editing the default settings file
wherever_you_installed_airflow/site-packages/airflow/config_templates/airflow_local_settings.py