# 日志处理程序：'caplog' fixture需要'logging'插件，但日志未配置

- **ID:** `python/pytest-capture-logging-handler`
- **领域:** python
- **类别:** config_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

pytest的caplog fixture需要pytest的logging插件，如果插件被禁用或未安装，就会报错。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 7.x | active | — | — |
| 8.x | active | — | — |

## 解决方案

1. **** (90% 成功率)
   ```
   pip install pytest-logging
# 在pytest.ini中添加
[pytest]
log_cli = true
   ```
2. **** (80% 成功率)
   ```
   [pytest]
addopts = -p no:logging
   ```

## 无效尝试

- **** — 问题不是pytest未安装，而是插件未启用 (50% 失败率)
- **** — caplog是pytest内置的，手动配置不会影响pytest的捕获 (70% 失败率)
