### Apache Airflow version

2.2.2 (latest released)

### Operating System

Linux-5.4.0-1056-azure-x86_64-with-glibc2.2.5

### Versions of Apache Airflow Providers

_No response_

### Deployment

Other Docker-based deployment

### Deployment details

kubernetes 1.21.2 (AKS)

### What happened

**DAG using logging class produce stack overflow and abort task.** It seems like a bug in /home/airflow/.local/lib/python3.8/site-packages/airflow/utils/log/secrets_masker.py 

**ENV:**
AIRFLOW__CORE__HIDE_SENSITIVE_VAR_CONN_FIELDS="False"

**Dag Code fragment:**

log_stream = StringIO()
logging.basicConfig(stream=log_stream, level=logging.DEBUG)

logger = logging.getLogger("airflow.task")
logger.addHandler(logging.StreamHandler(log_stream))
...
logger.info("------------------------------ ------------------- ------------------------------")

#####

**Log in worker pod:**

```
Fatal Python error: Cannot recover from stack overflow.
Python runtime state: initialized

Current thread 0x00007fbf8d8190c0 (most recent call first):
  File "/usr/local/lib/python3.8/posixpath.py", line 42 in _get_sep
  File "/usr/local/lib/python3.8/posixpath.py", line 143 in basename
  File "/usr/local/lib/python3.8/logging/__init__.py", line 322 in __init__
  File "/usr/local/lib/python3.8/logging/__init__.py", line 1556 in makeRecord
  File "/usr/local/lib/python3.8/logging/__init__.py", line 1587 in _log
  File "/usr/local/lib/python3.8/logging/__init__.py", line 1458 in warning
  File "/home/airflow/.local/lib/python3.8/site-packages/airflow/utils/log/secrets_masker.py", line 215 in _redact
  File "/home/airflow/.local/lib/python3.8/site-packages/airflow/utils/log/secrets_masker.py", line 208 in <genexpr>
  File "/home/airflow/.local/lib/python3.8/site-packages/airflow/utils/log/secrets_masker.py", line 208 in _redact
  File "/home/airflow/.local/lib/python3.8/site-packages/airflow/utils/log/secrets_masker.py", line 231 in redact
  File "/home/airflow/.local/lib/python3.8/site-packages/airflow/utils/log/secrets_masker.py", line 164 in filter
  File "/usr/local/lib/python3.8/logging/__init__.py", line 811 in filter
  File "/usr/local/lib/python3.8/logging/__init__.py", line 950 in handle
  File "/usr/local/lib/python3.8/logging/__init__.py", line 1661 in callHandlers
  File "/usr/local/lib/python3.8/logging/__init__.py", line 1599 in handle
  File "/usr/local/lib/python3.8/logging/__init__.py", line 1589 in _log
  File "/usr/local/lib/python3.8/logging/__init__.py", line 1458 in warning
  File "/home/airflow/.local/lib/python3.8/site-packages/airflow/utils/log/secrets_masker.py", line 215 in _redact
  File "/home/airflow/.local/lib/python3.8/site-packages/airflow/utils/log/secrets_masker.py", line 208 in <genexpr>
  File "/home/airflow/.local/lib/python3.8/site-packages/airflow/utils/log/secrets_masker.py", line 208 in _redact
  File "/home/airflow/.local/lib/python3.8/site-packages/airflow/utils/log/secrets_masker.py", line 231 in redact
  File "/home/airflow/.local/lib/python3.8/site-packages/airflow/utils/log/secrets_masker.py", line 164 in filter
  File "/usr/local/lib/python3.8/logging/__init__.py", line 811 in filter
  File "/usr/local/lib/python3.8/logging/__init__.py", line 950 in handle
  File "/usr/local/lib/python3.8/logging/__init__.py", line 1661 in callHandlers
  File "/usr/local/lib/python3.8/logging/__init__.py", line 1599 in handle
  File "/usr/local/lib/python3.8/logging/__init__.py", line 1589 in _log
  File "/usr/local/lib/python3.8/logging/__init__.py", line 1458 in warning
  File "/home/airflow/.local/lib/python3.8/site-packages/airflow/utils/log/secrets_masker.py", line 215 in _redact
  File "/home/airflow/.local/lib/python3.8/site-packages/airflow/utils/log/secrets_masker.py", line 208 in <genexpr>
  File "/home/airflow/.local/lib/python3.8/site-packages/airflow/utils/log/secrets_masker.py", line 208 in _redact
  File "/home/airflow/.local/lib/python3.8/site-packages/airflow/utils/log/secrets_masker.py", line 231 in redact
  File "/home/airflow/.local/lib/python3.8/site-packages/airflow/utils/log/secrets_masker.py", line 164 in filter
  File "/usr/local/lib/python3.8/logging/__init__.py", line 811 in filter
  File "/usr/local/lib/python3.8/logging/__init__.py", line 950 in handle
  File "/usr/local/lib/python3.8/logging/__init__.py", line 1661 in callHandlers
  File "/usr/local/lib/python3.8/logging/__init__.py", line 1599 in handle
  File "/usr/local/lib/python3.8/logging/__init__.py", line 1589 in _log
  File "/usr/local/lib/python3.8/logging/__init__.py", line 1458 in warning
  File "/home/airflow/.local/lib/python3.8/site-packages/airflow/utils/log/secrets_masker.py", line 215 in _redact
  File "/home/airflow/.local/lib/python3.8/site-packages/airflow/utils/log/secrets_masker.py", line 208 in <genexpr>
  File "/home/airflow/.local/lib/python3.8/site-packages/airflow/utils/log/secrets_masker.py", line 208 in _redact
  File "/home/airflow/.local/lib/python3.8/site-packages/airflow/utils/log/secrets_masker.py", line 208 in <genexpr>
  File "/home/airflow/.local/lib/python3.8/site-packages/airflow/utils/log/secrets_masker.py", line 208 in _redact
  File "/home/airflow/.local/lib/python3.8/site-packages/airflow/utils/log/secrets_masker.py", line 231 in redact
  File "/home/airflow/.local/lib/python3.8/site-packages/airflow/utils/log/secrets_masker.py", line 164 in filter
  File "/usr/local/lib/python3.8/logging/__init__.py", line 811 in filter
  File "/usr/local/lib/python3.8/logging/__init__.py", line 950 in handle
  File "/usr/local/lib/python3.8/logging/__init__.py", line 1661 in callHandlers
  File "/usr/local/lib/python3.8/logging/__init__.py", line 1599 in handle
  File "/usr/local/lib/python3.8/logging/__init__.py", line 1589 in _log
  File "/usr/local/lib/python3.8/logging/__init__.py", line 1458 in warning
  File "/home/airflow/.local/lib/python3.8/site-packages/airflow/utils/log/secrets_masker.py", line 215 in _redact
  File "/home/airflow/.local/lib/python3.8/site-packages/airflow/utils/log/secrets_masker.py", line 231 in redact
  File "/home/airflow/.local/lib/python3.8/site-packages/airflow/utils/log/secrets_masker.py", line 164 in filter
  File "/usr/local/lib/python3.8/logging/__init__.py", line 811 in filter
  File "/usr/local/lib/python3.8/logging/__init__.py", line 950 in handle
  File "/usr/local/lib/python3.8/logging/__init__.py", line 1661 in callHandlers
  File "/usr/local/lib/python3.8/logging/__init__.py", line 1599 in handle
  File "/usr/local/lib/python3.8/logging/__init__.py", line 1589 in _log
  File "/usr/local/lib/python3.8/logging/__init__.py", line 1458 in warning
  File "/home/airflow/.local/lib/python3.8/site-packages/airflow/utils/log/secrets_masker.py", line 215 in _redact
  File "/home/airflow/.local/lib/python3.8/site-packages/airflow/utils/log/secrets_masker.py", line 208 in <genexpr>
  File "/home/airflow/.local/lib/python3.8/site-packages/airflow/utils/log/secrets_masker.py", line 208 in _redact
  File "/home/airflow/.local/lib/python3.8/site-packages/airflow/utils/log/secrets_masker.py", line 231 in redact
  File "/home/airflow/.local/lib/python3.8/site-packages/airflow/utils/log/secrets_masker.py", line 164 in filter
  File "/usr/local/lib/python3.8/logging/__init__.py", line 811 in filter
  File "/usr/local/lib/python3.8/logging/__init__.py", line 950 in handle
  File "/usr/local/lib/python3.8/logging/__init__.py", line 1661 in callHandlers
  File "/usr/local/lib/python3.8/logging/__init__.py", line 1599 in handle
  File "/usr/local/lib/python3.8/logging/__init__.py", line 1589 in _log
  File "/usr/local/lib/python3.8/logging/__init__.py", line 1458 in warning
  File "/home/airflow/.local/lib/python3.8/site-packages/airflow/utils/log/secrets_masker.py", line 215 in _redact
  File "/home/airflow/.local/lib/python3.8/site-packages/airflow/utils/log/secrets_masker.py", line 208 in <genexpr>
  File "/home/airflow/.local/lib/python3.8/site-packages/airflow/utils/log/secrets_masker.py", line 208 in _redact
  File "/home/airflow/.local/lib/python3.8/site-packages/airflow/utils/log/secrets_masker.py", line 231 in redact
  File "/home/airflow/.local/lib/python3.8/site-packages/airflow/utils/log/secrets_masker.py", line 164 in filter
  File "/usr/local/lib/python3.8/logging/__init__.py", line 811 in filter
  File "/usr/local/lib/python3.8/logging/__init__.py", line 950 in handle
  File "/usr/local/lib/python3.8/logging/__init__.py", line 1661 in callHandlers
  File "/usr/local/lib/python3.8/logging/__init__.py", line 1599 in handle
  File "/usr/local/lib/python3.8/logging/__init__.py", line 1589 in _log
  File "/usr/local/lib/python3.8/logging/__init__.py", line 1458 in warning
  File "/home/airflow/.local/lib/python3.8/site-packages/airflow/utils/log/secrets_masker.py", line 215 in _redact
  File "/home/airflow/.local/lib/python3.8/site-packages/airflow/utils/log/secrets_masker.py", line 208 in <genexpr>
  File "/home/airflow/.local/lib/python3.8/site-packages/airflow/utils/log/secrets_masker.py", line 208 in _redact
  File "/home/airflow/.local/lib/python3.8/site-packages/airflow/utils/log/secrets_masker.py", line 231 in redact
  File "/home/airflow/.local/lib/python3.8/site-packages/airflow/utils/log/secrets_masker.py", line 164 in filter
  File "/usr/local/lib/python3.8/logging/__init__.py", line 811 in filter
  File "/usr/local/lib/python3.8/logging/__init__.py", line 950 in handle
  File "/usr/local/lib/python3.8/logging/__init__.py", line 1661 in callHandlers
  File "/usr/local/lib/python3.8/logging/__init__.py", line 1599 in handle
  File "/usr/local/lib/python3.8/logging/__init__.py", line 1589 in _log
  File "/usr/local/lib/python3.8/logging/__init__.py", line 1458 in warning
  File "/home/airflow/.local/lib/python3.8/site-packages/airflow/utils/log/secrets_masker.py", line 215 in _redact
  File "/home/airflow/.local/lib/python3.8/site-packages/airflow/utils/log/secrets_masker.py", line 208 in <genexpr>
  File "/home/airflow/.local/lib/python3.8/site-packages/airflow/utils/log/secrets_masker.py", line 208 in _redact
  File "/home/airflow/.local/lib/python3.8/site-packages/airflow/utils/log/secrets_masker.py", line 231 in redact
  File "/home/airflow/.local/lib/python3.8/site-packages/airflow/utils/log/secrets_masker.py", line 164 in filter
  File "/usr/local/lib/python3.8/logging/__init__.py", line 811 in filter
```




### What you expected to happen

_No response_

### How to reproduce

_No response_

### Anything else

_No response_

### Are you willing to submit PR?

- [ ] Yes I am willing to submit a PR!

### Code of Conduct

- [X] I agree to follow this project's [Code of Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)

airflow/utils/log/secrets_masker.py
if isinstance(item, dict):
                return {
                    dict_key: self._redact(subval, name=dict_key, depth=(depth + 1))
                    for dict_key, subval in item.items()
                }
            elif isinstance(item, str):
                if self.replacer:
                    
                    
                    
                    return self.replacer.sub('***', item)
                return item
            elif isinstance(item, (tuple, set)):
                
                return tuple(self._redact(subval, name=None, depth=(depth + 1)) for subval in item)
            elif isinstance(item, list):
                return [self._redact(subval, name=None, depth=(depth + 1)) for subval in item]
            else:
                return item
        
        except Exception as e:
            log.warning(
                "Unable to redact %r, please report this via <https://github.com/apache/airflow/issues>. "
                "Error was: %s: %s",
                item,
                type(e).__name__,
                str(e),
            )
            return item
    def redact(self, item: "RedactableItem", name: Optional[str] = None) -> "RedactableItem":