# AssertionError: assert 'expected message' in []

- **ID:** `python/pytest-caplog-not-capturing`
- **领域:** python
- **类别:** config_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

caplog 夹具未捕获任何日志记录，因为记录器的级别高于日志消息级别，或者记录器未传播到根记录器。

## 版本兼容性

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

## 解决方案

1. **** (92% 成功率)
   ```
   def test_logging(caplog):
    caplog.set_level(logging.INFO)
    my_function()
    assert 'expected message' in caplog.text
   ```
2. **** (88% 成功率)
   ```
   logger = logging.getLogger('myapp')
logger.propagate = True
# Or use caplog.set_level with the specific logger name
   ```

## 无效尝试

- **** — The level must be set before the log call. Setting it after has no effect on already-emitted records. (85% 失败率)
- **** — This bypasses the logging system entirely and does not test the actual logging behavior. It also clutters test output. (70% 失败率)
