GitHub user rmaziere created a discussion: Failed to decrease the provider log 
level

Hi,

I use Apache Airflow 3.1.5, and I would like to decrease the log level of the 
provider `common.sql`.
My problem is that the `SQLExecuteQueryOperator` is too verbose, it logs all 
SQL queries and empties the disk.
An example :
```
{"timestamp":"2026-01-12T04:50:14.611801Z","level":"warning","event":"SQLExecuteQueryOperator.execute
 cannot be called outside of the Task 
Runner!","logger":"airflow.task.operators.airflow.providers.common.sql.operators.sql.SQLExecuteQueryOperator","filename":"operator.py","lineno":411}
{"timestamp":"2026-01-12T04:50:14.612001Z","level":"info","event":"Executing: 
\n                    INSERT INTO main.activites_coop (\n                       
 coop_id, type, structure_id , personne_id, date, duree, lieu_code_insee,\n     
                   type_lieu, autonomie, structure_de_redirection, 
oriente_vers_structure, precisions_demarche,\n                        
degre_de_finalisation_demarche, titre_atelier, niveau_atelier,\n                
        accompagnements, thematiques, materiels, 
thematiques_demarche_administrative\n                    ) VALUES (%s, %s, %s, 
%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s), (%s, %s, %s, 
%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s), (%s, %s, %s, 
%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s), (%s, %s, %s, 
%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s), (%s, %s, %s, 
%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s), (%s, %s, %s, 
%s, %s, %s, %s, %s, %s, %
 s, %s, %s, %s, %s, %s, %s, %s, %s, %s), (%s, %s, %s, %s, %s, %s, %s, %s, %s, 
%s, %s, %s, %s, %s, %s, %s, %s, %s, %s), (%s, %s, %s, %s, %s, %s, %s, %s, %s, 
%s, %s, %s, %s, %s, %s, %s, %s, %s, %s),
[...]
```
I would like to set the log level of this operator to WARNING to not log the 
INFO.
So I read the documentation `Logging and Monitoring architecture`, `Logging for 
Tasks`, `Advanced logging configuration` and I tried the [Custom logger for 
Operators, Hooks and 
Tasks](https://airflow.apache.org/docs/apache-airflow/stable/administration-and-deployment/logging-monitoring/advanced-logging-configuration.html#custom-logger-for-operators-hooks-and-tasks).

I created the `config/logging_config.py`, with the content:
```py
from copy import deepcopy
from pydantic.utils import deep_update
from airflow.config_templates.airflow_local_settings import 
DEFAULT_LOGGING_CONFIG

LOGGING_CONFIG = deep_update(
    deepcopy(DEFAULT_LOGGING_CONFIG),
    {
        "loggers": {
            
"airflow.task.operators.airflow.providers.common.sql.operators.sql.SQLExecuteQueryOperator":
 {
                "handlers": ["task"],
                "level": "WARNING",
                "propagate": False,
            },
            "airflow.task.operators.airflow.providers.common.sql.hooks": {
                "handlers": ["task"],
                "level": "WARNING",
                "propagate": False,
            },
            
"airflow.task.hooks.airflow.providers.postgres.hooks.postgres.PostgresHook": {
                "handlers": ["task"],
                "level": "WARNING",
                "propagate": False,
            },
        }
    },
)

REMOTE_TASK_LOG = None
```

I modified the airflow.cfg with
```
logging_config_class = config.logging_config.LOGGING_CONFIG
```

Then I restarted the services.

But that didn't change anything. I tried different configurations, but I'm 
still getting unwanted logs (see example below):
```
INFO - Executing: SELECT COUNT(*) FROM 
table;source=airflow.task.operators.airflow.providers.common.sql.operators.sql.SQLExecuteQueryOperator
 loc=sql.py:314 
INFO - Running statement: SELECT COUNT(*) FROM table;, parameters: 
Nonesource=airflow.task.hooks.airflow.providers.postgres.hooks.postgres.PostgresHook
 loc=sql.py:806 
INFO - Rows affected: 
1source=airflow.task.hooks.airflow.providers.postgres.hooks.postgres.PostgresHook
 loc=sql.py:818 
```

I really can't figure out what's wrong. If anyone has any ideas to help me, I 
would be very grateful.


# Airflow info
```
Apache Airflow
version                | 3.1.5                                                  
                                                             
executor               | LocalExecutor                                          
                                                             
task_logging_handler   | airflow.utils.log.file_task_handler.FileTaskHandler    
                                                             
sql_alchemy_conn       | postgresql+psycopg2://****
dags_folder            | /opt/airflow/airflow/dags                              
                                                             
plugins_folder         | /opt/airflow/airflow/plugins                           
                                                             
base_log_folder        | /opt/airflow/airflow/logs                              
                                                             
remote_base_log_folder |                                                        
                                                             
                                                                                
                                                             

System info
OS              | Linux                                                         
                                                                                
                
architecture    | x86_64                                                        
                                                                                
                
uname           | uname_result(system='Linux', node='airflow', 
release='6.1.0-41-cloud-amd64', version='#1 SMP PREEMPT_DYNAMIC Debian 
6.1.158-1 (2025-11-09)', machine='x86_64')
locale          | ('fr_FR', 'UTF-8')                                            
                                                                                
                
python_version  | 3.11.2 (main, Apr 28 2025, 14:11:48) [GCC 12.2.0]             
                                                                                
                
python_location | /opt/airflow/env/bin/python3.11                               
                                                                                
                
                                                                                
                                                                                
                

Tools info
[...]                                        
psql            | psql (PostgreSQL) 18.1 (Debian 18.1-1.pgdg12+2)           
                                                                            

Paths info
airflow_home    | /opt/airflow/airflow                                          
                                                                                
                                                        
system_path     | /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin  
                                                                                
                                                        
python_path     | 
/opt/airflow/env/bin:/usr/lib/python311.zip:/usr/lib/python3.11:/usr/lib/python3.11/lib-dynload:/opt/airflow/env/lib/python3.11/site-packages:/opt/airflow/airflow/config:/opt/airflow/airflow/plugins
airflow_on_path | False                                                         
                                                                                
                                                        
                                                                                
                                                                                
                                                        

Providers info
apache-airflow-providers-amazon        | 9.18.0
apache-airflow-providers-common-compat | 1.10.0
apache-airflow-providers-common-io     | 1.7.0 
apache-airflow-providers-common-sql    | 1.30.0
apache-airflow-providers-fab           | 2.4.0 
apache-airflow-providers-http          | 5.6.0 
apache-airflow-providers-mongo         | 5.3.0 
apache-airflow-providers-postgres      | 6.5.0 
apache-airflow-providers-smtp          | 2.4.0 
apache-airflow-providers-ssh           | 4.2.0 
apache-airflow-providers-standard      | 1.10.0
```

GitHub link: https://github.com/apache/airflow/discussions/60554

----
This is an automatically sent email for [email protected].
To unsubscribe, please send an email to: [email protected]

Reply via email to