GitHub user adamliter closed the discussion with a comment: How to pass logging level values with PythonVirtualenvOperator when system_site_packages=False?
Never mind. I didn't fully understand what has happening. After poking around a bit in https://github.com/apache/airflow/issues/34865 and https://github.com/apache/airflow/issues/27012#issuecomment-1361342168, I see that the `PythonVirtualenvOperator` is just grabbing stuff from `STDOUT` of the subprocess and logging it as an info log in its own logger. That's a little bit of a bummer insofar as you won't be able to see the log in the Airflow UI with the appropriate log level attributed to it. However, what my minimal example above comes down to is the fact that `system_site_packages=False` means that the subprocess is _not_ inheriting the logger setup of the system site environment. You can actually get the log above to show up by explicitly configuring the logging (since it's no longer inheriting configuration from system site packages); for example: ```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__) logging.basicConfig(level=logging.INFO) 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, python_callable=main, serializer="dill", ) ``` GitHub link: https://github.com/apache/airflow/discussions/49921#discussioncomment-12986672 ---- This is an automatically sent email for [email protected]. To unsubscribe, please send an email to: [email protected]
