litellm - ✅(Solved) Fix [Bug]: log_raw_request: true not working [1 pull requests, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
BerriAI/litellm#23442Fetched 2026-04-08 00:44:20
View on GitHub
Comments
0
Participants
1
Timeline
4
Reactions
0
Participants
Timeline (top)
labeled ×2cross-referenced ×1referenced ×1

Fix Action

Fixed

PR fix notes

PR #24511: fix(logging): honour metadata log_raw_request flag per request

Description (problem / solution / changelog)

metadata: {"log_raw_request": true} was documented but never wired up. The raw-request logging block in pre_call only checked the global litellm.log_raw_request_response flag and the Logging instance flag, never the per-request metadata key.

Move the metadata extraction before the guard and add _metadata.get("log_raw_request") is True to the condition so callers can opt in per-request without touching global config.

Fixes #23442

Relevant issues

<!-- e.g. "Fixes #000" -->

Pre-Submission checklist

Please complete all items before asking a LiteLLM maintainer to review your PR

  • I have Added testing in the tests/test_litellm/ directory, Adding at least 1 test is a hard requirement - see details
  • My PR passes all unit tests on make test-unit
  • My PR's scope is as isolated as possible, it only solves 1 specific problem
  • I have requested a Greptile review by commenting @greptileai and received a Confidence Score of at least 4/5 before requesting a maintainer review

Type

<!-- Select the type of Pull Request --> <!-- Keep only the necessary ones -->

🐛 Bug Fix

Changed files

  • litellm/litellm_core_utils/litellm_logging.py (modified, +3/-2)
  • tests/test_litellm/litellm_core_utils/test_litellm_logging.py (modified, +66/-0)
RAW_BUFFERClick to expand / collapse

Check for existing issues

  • I have searched the existing issues and checked that my issue is not a duplicate.

What happened?

log_raw_request: true not working

Steps to Reproduce

{ "model: xxx, "metadata": { "log_raw_request": true } }

Relevant log output

What part of LiteLLM is this about?

Proxy

What LiteLLM version are you on ?

v1.82.0

Twitter / LinkedIn details

No response

extent analysis

Fix Plan

To enable logging of raw requests, you need to modify the configuration of the LiteLLM proxy.

Steps to Fix

  • Update the log_raw_request setting in the proxy configuration to true.
  • Ensure that the logging module is properly configured to handle the raw request logs.

Example Code

# Update the proxy configuration
proxy_config = {
    "model": "xxx",
    "metadata": {
        "log_raw_request": True
    }
}

# Enable logging of raw requests
import logging
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)

# Log raw requests
def log_raw_request(request):
    logger.info("Raw Request: %s", request)

# Example usage
raw_request = {"url": "/example", "method": "GET"}
log_raw_request(raw_request)

Verification

To verify that the fix worked, check the log output for the raw request logs. You should see the raw request data being logged.

Extra Tips

  • Make sure to update the logging module configuration to handle the raw request logs properly.
  • You can also use a logging library like Loggly or Splunk to handle and analyze the raw request logs.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

litellm - ✅(Solved) Fix [Bug]: log_raw_request: true not working [1 pull requests, 1 participants]