GitHub user adamliter closed a discussion: How to pass logging level values
with PythonVirtualenvOperator when system_site_packages=False?
Is there any way to get logs to show up in the Airflow UI from tasks defined
with the `PythonVirtualenvOperator` when `system_site_packages=False`. The
following DAG will not show the `"hello from task"` log in the Airflow UI
unless you comment out `system_site_packages=False`:
```python
from datetime import timedelta
from airflow.models.dag import DAG
from airflow.providers.standard.operators.python import PythonVirtualenvOperator
from pendulum import datetime
def main() -> None:
import logging
logger = logging.getLogger(__name__)
logger.info("hello from task")
with DAG(
dag_id="logging_dag",
start_date=datetime(2025, 4, 28, 0, 0, tz="UTC"),
schedule=timedelta(hours=0.5),
catchup=False,
) as dag:
logging_task = PythonVirtualenvOperator(
task_id="logging_task",
requirements=["requests"],
system_site_packages=False, # disables logging
python_callable=main,
serializer="dill",
)
```
GitHub link: https://github.com/apache/airflow/discussions/49921
----
This is an automatically sent email for [email protected].
To unsubscribe, please send an email to: [email protected]