Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Apache Airflow: Control over logging [Disable/Adjust logging level]

Tags:

python

airflow

I am using Airflow 1.7.1.3 installed using pip

I would like to limit the logging to ERROR level for the workflow being executed by the scheduler. Could not find anything beyond setting log files location in the settings.py file.

Also the online resources led me to this google group discussion here but not much info here as well

Any idea how to control logging in Airflow?

like image 369
Priyank Mehta Avatar asked Feb 11 '17 07:02

Priyank Mehta


People also ask

How do I change the logging level of Airflow?

For example, if you wanted to change your logging level from the default INFO to only log LogRecords with a level of ERROR or above, you could set logging_level = ERROR in airflow. cfg or define an environment variable AIRFLOW__LOGGING__LOGGING_LEVEL=ERROR .

How do you check Airflow logs?

You can also view the logs in the Airflow web interface. Streaming logs: These logs are a superset of the logs in Airflow. To access streaming logs, you can go to the logs tab of Environment details page in Google Cloud console, use the Cloud Logging, or use Cloud Monitoring. Logging and Monitoring quotas apply.

How do I change my Airflow config?

The first time you run Airflow, it will create a file called airflow. cfg in your $AIRFLOW_HOME directory ( ~/airflow by default). This file contains Airflow's configuration and you can edit it to change any of the settings.

How does airflow write logs for tasks?

Airflow writes logs for tasks in a way that allows to see the logs for each task separately via Airflow UI. The Core Airflow implements writing and serving logs locally. However you can also write logs to remote services - via community providers, but you can also write your own loggers.

How to change the log level for the Apache webserver?

To change the log level for the Apache webserver, we have to add the below line of code in the Apache webserver configuration file: In the above line, we have set the log level to warning. Below we have a sample Apache configuration file, where we have also used the ErrorLog configuration to change the log file location too, to a custom location.

Where are logs stored in airflow?

By default, logs are placed in the AIRFLOW_HOME directory. The following convention is followed while naming logs: {dag_id}/ {task_id}/ {logical_date}/ {try_number}.log In addition, users can supply a remote location to store current logs and backups. In the Airflow Web UI, remote logs take precedence over local logs when remote logging is enabled.

How do I view logs in real time in airflow?

See Modules Management for details on how Python and Airflow manage modules. Most task handlers send logs upon completion of a task. In order to view logs in real time, airflow automatically starts an http server to serve the logs in the following cases: If SchedulerExecutor or LocalExecutor is used, then when airflow scheduler is running.


2 Answers

I tried below work around and it seems to be working to set LOGGING_LEVEL outside of settings.py:

  • Update settings.py:

    • Remove or comment line:
      LOGGING_LEVEL = logging.INFO

    • Add line:
      LOGGING_LEVEL = os.path.expanduser(conf.get('core', 'LOGGING_LEVEL'))

  • Update airflow.cfg configuration file:

    • Add line under [core]: logging_level = WARN

    • Restart webserver and scheduler services

  • Use environment vaiable AIRFLOW__CORE__LOGGING_LEVEL=WARN.

See the official docs for details.

like image 121
Kiran Avatar answered Sep 19 '22 15:09

Kiran


The logging functionality and its configuration will be changed in version 1.9 with this commit

like image 38
Dimo Boyadzhiev Avatar answered Sep 20 '22 15:09

Dimo Boyadzhiev