{
  "id": "python/pytest-capture-logging-not-showing",
  "signature": "Logging output not captured: Captured logs are not displayed in the test report even with -s flag",
  "signature_zh": "日志输出未捕获：即使使用 -s 标志，捕获的日志也不会显示在测试报告中",
  "regex": "Logging\\ output\\ not\\ captured:\\ Captured\\ logs\\ are\\ not\\ displayed\\ in\\ the\\ test\\ report\\ even\\ with\\ \\-s\\ flag",
  "domain": "python",
  "category": "config_error",
  "subcategory": null,
  "root_cause": "Logging is configured at the root level without a handler that pytest can capture, or the caplog fixture is not used.",
  "root_cause_type": "generic",
  "root_cause_zh": "日志在根级别配置，没有 pytest 可以捕获的处理程序，或者未使用 caplog fixture。",
  "versions": [
    {
      "version": "3.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "This configures logging globally but may not integrate with pytest's capture mechanism.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Print statements are captured, but logging is not, so the problem remains.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.95,
      "how": "def test_logging(caplog):\n    with caplog.at_level(logging.DEBUG):\n        function_that_logs()\n    assert 'Expected log' in caplog.text",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.9,
      "how": "[pytest]\nlog_cli = true\nlog_level = DEBUG",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": null,
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.84,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-04-05",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}