Logging configuration replaces the global logging settings (Always / Never / Header controlled). See Migrating to logging configs for the mapping from global settings.
How logging configs work
Logging configuration consists of a set of independent rules. Each rule defines which requests it applies to and whether those requests are logged. During evaluation:- Every matching rule is checked. The gateway finds all rules whose conditions match the incoming request.
- Logging is deny-wins. If any matching rule has Log turned off, the request and response bodies are not logged.
- Redactions are merged. When logging is allowed, the redaction patterns from every matching rule are applied to the logged copy.
Think of matching rules as deny-wins for logging: a request body is stored only when every rule it matches allows logging. A single rule with Log off is enough to suppress the body.
When no logging config matches a request, the gateway falls back to the per-request
X-TFY-LOGGING-CONFIG header behavior. See Request Logging.
Setting up a logging config
To create a rule, go to AI Gateway → Policies → Logging Config and click Add Rule. The rule form has three parts: a Configuration Name, the Conditions that select matching requests, and the Log and Redaction settings.Configuration name
A unique Rule ID that identifies the logging config within your tenant. Choose a descriptive name likenever-log-finance or log-support-with-redaction.
Conditions
Conditions define which requests the rule applies to. Add filters with + Add Filters. Filters use AND logic, so a request must match every filter you add.If you leave conditions empty, the rule matches every request in your tenant. This is useful for a default rule that logs everything.

Log decision and redaction
Log requests
The Log Requests toggle controls whether requests matched by this rule have their request and response bodies logged. In YAML, this is thelog field.
- ON: matching requests are logged (subject to deny-wins across all matching rules).
- OFF: matching requests are not logged. The body is suppressed even if another rule would allow it.
Redaction
Enable Redaction to remove sensitive values from the logged copy while leaving the live request untouched. You can combine predefined patterns and custom patterns.- Predefined Patterns: a catalog of built-in patterns such as
email,us_ssn, andcredit_card. This is the same catalog used by the Regex Pattern Match guardrail. See the full Preset Patterns reference for every available pattern, its regex, and its default redaction text. - Custom Patterns: your own regex patterns with an optional Redaction Text (defaults to
[REDACTED]). For example, redact internal customer IDs with patterncust_[A-Za-z0-9]{12}and redaction text[REDACTED CUSTOMER_ID].

Verifying in Request Traces
Logging configuration only controls whether request and response bodies are stored, and redacts sensitive values in the stored copy. Everything else (cost, tokens, latency, and metadata) is always recorded. To confirm a rule is working, open AI Gateway → Request Traces and inspect a matching request. The trace below shows a rule with a customcust_... pattern and the email preset: the customer ID and email are redacted in both the request and response bodies, while cost, tokens, and latency remain fully visible.

The root span records
tfy.logging.prompt_logging_enabled and tfy.logging.matched_config_names, which lists the rules that matched the request. Use these attributes to trace a logging decision back to the rules that produced it. For programmatic access, see API Access to Logs.Practical examples
Each example shows both the UI configuration and the equivalent YAML. Click Apply as YAML in the rule form to paste or edit YAML directly.Never log a sensitive team
Never log a sensitive team
Suppress body logging entirely for a team that handles sensitive data.
- UI
- YAML
How it works: Any request from a member of
finance-sensitive matches this rule. Because Log is off, the request and response bodies are never stored.Log with email and SSN redaction
Log with email and SSN redaction
Log a team’s requests but strip emails and SSNs from the stored copy.
- UI
- YAML
How it works: Support team requests are logged, but any email address or US SSN in the request or response is replaced with its redaction text in the stored copy.
Skip one model, log everything else
Skip one model, log everything else
Skip logging for a specific user on an internal model, while a default rule logs everything else. These are two separate rules.
- UI
- YAML
How it works: For that user calling the internal model, both rules match, and deny-wins means the body is not logged. Every other request matches only
log-default, so it is logged.Metadata match with a custom redaction pattern
Metadata match with a custom redaction pattern
Log production requests and redact internal customer IDs using a custom regex.Any value matching
- UI
- YAML
Requests must include the header:
cust_[A-Za-z0-9]{12} is replaced with [REDACTED CUSTOMER_ID] in the logged copy.YAML configuration reference
YAML structure reference
YAML structure reference