Skip to content

Commit d3f0a2c

Browse files
fix(airflow): Allow overriding the logging configuration in Airflow 3.1 (#1445)
* fix(airflow): Allow overriding the logging configuration * fix(airflow): Use the log levels defined in stdlib_config for structlog
1 parent 89665bb commit d3f0a2c

2 files changed

Lines changed: 73 additions & 0 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ All notable changes to this project will be documented in this file.
8080
- superset: Pin setup-tools to ensure pkg_resources are installed (needed for `4.1.4` builds) ([#1428]).
8181
- ubi10-rust-builder: Add gzip dependency for the ONBUILD step ([#1436]).
8282
- airflow: Pin virtualenv to prevent hatch pulling in a version with a breaking change ([#1437]).
83+
- airflow: Allow overriding the logging configuration in Airflow 3.1.x ([#1445]).
8384

8485
[#1336]: https://github.com/stackabletech/docker-images/pull/1336
8586
[#1337]: https://github.com/stackabletech/docker-images/pull/1337
@@ -127,6 +128,7 @@ All notable changes to this project will be documented in this file.
127128
[#1436]: https://github.com/stackabletech/docker-images/pull/1436
128129
[#1437]: https://github.com/stackabletech/docker-images/pull/1437
129130
[#1442]: https://github.com/stackabletech/docker-images/pull/1442
131+
[#1445]: https://github.com/stackabletech/docker-images/pull/1445
130132
[#1447]: https://github.com/stackabletech/docker-images/pull/1447
131133

132134
## [25.11.0] - 2025-11-07
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
From 583a680fc1c6aba63d44c53db487de35a9bf6ed5 Mon Sep 17 00:00:00 2001
2+
From: Siegfried Weber <mail@siegfriedweber.net>
3+
Date: Mon, 9 Mar 2026 10:11:28 +0100
4+
Subject: Allow overriding the logging configuration
5+
6+
---
7+
.../src/airflow_shared/logging/structlog.py | 30 ++++++++++++++++++-
8+
1 file changed, 29 insertions(+), 1 deletion(-)
9+
10+
diff --git a/shared/logging/src/airflow_shared/logging/structlog.py b/shared/logging/src/airflow_shared/logging/structlog.py
11+
index 2d901b8303..949db2732c 100644
12+
--- a/shared/logging/src/airflow_shared/logging/structlog.py
13+
+++ b/shared/logging/src/airflow_shared/logging/structlog.py
14+
@@ -376,6 +376,18 @@ def structlog_processors(
15+
return shared_processors, console, console
16+
17+
18+
+def update_config(
19+
+ config: dict,
20+
+ updates: Mapping,
21+
+):
22+
+ for key, value in updates.items():
23+
+ if isinstance(value, Mapping):
24+
+ config[key] = update_config(config.get(key, {}), value)
25+
+ else:
26+
+ config[key] = value
27+
+ return config
28+
+
29+
+
30+
def configure_logging(
31+
*,
32+
json_output: bool = False,
33+
@@ -452,6 +464,19 @@ def configure_logging(
34+
else:
35+
PER_LOGGER_LEVELS[log] = loglevel
36+
37+
+ # Use the log levels defined in stdlib_config for structlog
38+
+ logger_configs = stdlib_config.get("loggers", {})
39+
+ logger_configs[""] = stdlib_config.get("root", {})
40+
+ for logger, logger_config in logger_configs.items():
41+
+ if "level" in logger_config:
42+
+ loglevel = logger_config["level"]
43+
+ if isinstance(loglevel, str):
44+
+ try:
45+
+ loglevel = NAME_TO_LEVEL[loglevel.lower()]
46+
+ except KeyError:
47+
+ raise ValueError(f"Invalid log level for logger {logger!r}: {loglevel!r}") from None
48+
+ PER_LOGGER_LEVELS[logger] = loglevel
49+
+
50+
shared_pre_chain, for_stdlib, for_structlog = structlog_processors(
51+
json_output,
52+
log_format=log_format,
53+
@@ -494,7 +519,7 @@ def configure_logging(
54+
55+
import logging.config
56+
57+
- config = {**stdlib_config}
58+
+ config = {}
59+
config.setdefault("version", 1)
60+
config.setdefault("disable_existing_loggers", False)
61+
config["formatters"] = {**config.get("formatters", {})}
62+
@@ -547,6 +572,9 @@ def configure_logging(
63+
"propagate": True,
64+
}
65+
66+
+ # Merge stdlib_config into config and override existing values
67+
+ update_config(config, stdlib_config)
68+
+
69+
logging.config.dictConfig(config)
70+
71+

0 commit comments

Comments
 (0)