# LogCaptureError: Failed to capture log output: 'NoneType' object has no attribute 'write'

- **ID:** `python/pytest-logging-capture-failure`
- **Domain:** python
- **Category:** runtime_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

The logging capture mechanism in pytest fails because a logger has no handlers or the handler's stream is None, often after reconfiguration.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 3.8 | active | — | — |
| 3.9 | active | — | — |
| 3.10 | active | — | — |
| 3.11 | active | — | — |
| 3.12 | active | — | — |

## Workarounds

1. **** (90% success)
   ```
   Reset the logger configuration in conftest.py: `logging.basicConfig(handlers=[logging.StreamHandler()], force=True)`
   ```
2. **** (95% success)
   ```
   Avoid modifying root logger handlers in test code; use pytest's built-in caplog fixture instead.
   ```

## Dead Ends

- **** — This removes all log output from test reports, making debugging harder. (70% fail)
- **** — This can interfere with the test's logging assertions and may not fix the root cause. (80% fail)
