litellm/tests/logging_callback_tests
shin-bot-litellm c7a22921dc
feat: add standard_logging_payload_excluded_fields config option (#20831)
Adds a new config option to exclude specific fields from StandardLoggingPayload
before any callback receives it. This provides a general approach to control
what data is logged across ALL integrations (S3, GCS, Datadog, etc.).

## Changes

1. **litellm/__init__.py**: Added new global setting
   `standard_logging_payload_excluded_fields: Optional[List[str]] = None`

2. **litellm/integrations/custom_logger.py**: Modified
   `redact_standard_logging_payload_from_model_call_details()` to:
   - Remove specified fields entirely from the StandardLoggingPayload
   - Works alongside existing `turn_off_message_logging` feature
   - Excluded fields take precedence (removed rather than redacted)

3. **tests/**: Added comprehensive test suite with 17 tests covering:
   - Single/multiple field exclusion
   - Interaction with turn_off_message_logging
   - Original payload immutability
   - Config loading via setattr (proxy pattern)
   - Edge cases (empty list, non-existent fields, None standard_logging_object)

## Usage

```yaml
litellm_settings:
  success_callback: ["s3"]
  standard_logging_payload_excluded_fields: ["response", "messages"]
```

This removes the `response` and `messages` fields from logs before any
callback processes them, reducing log size and improving privacy compliance.

## Available Fields

The fields match StandardLoggingPayload TypedDict keys including:
- messages, response (large payload fields)
- metadata, hidden_params, model_parameters
- error_str, error_information
- And all other StandardLoggingPayload fields

Closes the need for per-integration flags like `s3_log_response`.
2026-02-10 22:16:41 -08:00
..
gcs_pub_sub_body
langfuse_expected_request_body fix: test_langfuse_logging_completion_with_bedrock_llm_response 2026-01-02 15:55:02 +09:00
base_test.py
conftest.py
create_mock_standard_logging_payload.py
gettysburg.wav
log.txt
test_alerting.py test: update langfuse trace_id tests to use litellm_trace_id 2026-01-22 06:19:43 +09:00
test_amazing_s3_logs.py
test_assemble_streaming_responses.py
test_azure_blob_storage.py
test_bedrock_knowledgebase_hook.py
test_built_in_tools_cost_tracking.py
test_custom_callback_router.py
test_datadog_llm_obs.py
test_datadog.py
test_dynamic_otel_keys.py Litellm fix langfuse otel trace (#20382) 2026-02-03 22:40:19 -08:00
test_gcs_pub_sub.py fix metadata.cost_breakdown 2026-01-07 14:17:08 +05:30
test_generic_api_callback.py Add log_format parameter to GenericAPILogger (#18587) 2026-01-02 23:28:30 +05:30
test_humanloop_unit_tests.py
test_langfuse_e2e_test.py
test_langfuse_unit_tests.py
test_langsmith_unit_test.py Fix all 130126 tests 2026-01-14 17:47:03 +05:30
test_log_db_redis_services.py
test_logging_redaction_e2e_test.py
test_moderations_api_logging.py
test_opentelemetry_unit_tests.py Use already configured opentelemetry providers 2026-01-01 19:06:55 -08:00
test_otel_logging.py added tests 2026-01-21 14:41:35 -05:00
test_pagerduty_alerting.py
test_posthog.py posthog serilization fix (#20668) 2026-02-07 14:24:32 -08:00
test_spend_logs.py
test_sqs_logger.py
test_standard_logging_payload_excluded_fields.py feat: add standard_logging_payload_excluded_fields config option (#20831) 2026-02-10 22:16:41 -08:00
test_standard_logging_payload.py perf: optimize get_standard_logging_metadata with set intersection (#19685) 2026-02-07 09:35:03 -08:00
test_token_counting.py
test_unit_test_litellm_logging.py
test_unit_tests_init_callbacks.py
test_view_request_resp_logs.py