INTEGRITY Cloudflare Docs

Log mode versus production mode

AI Security for Apps can operate in two distinct modes. Understanding the trade-offs between them helps you choose the right approach for your stage of deployment.

Comparison

Feature Production mode Log mode
How it works You write WAF custom rules using AI Security for Apps detection fields You enable the AI Security Log Mode Ruleset with pre-built rules
Prompt logging No — only request metadata is logged Yes — the full request body is logged (encrypted via payload logging)
Response logging No — use AI Gateway if response visibility is required No — same limitation
Policy flexibility Full — combine injection scores, PII categories, bot scores, custom topics, and more Limited — three fixed rules (PII detected, unsafe topic detected, prompt injection detected) with no score-based or subcategory logic
Blocking behavior Customizable — issue custom responses including custom JSON Default WAF block page only
Best for Production traffic with granular control Evaluation and testing — correlate prompts with detection results to tune thresholds

Production mode

Production mode is the standard operating mode. You enable AI Security for Apps and create custom rules using the detection fields it populates. This gives you full control over:

Example production rule expression:
(cf.llm.prompt.injection_score lt 30 and cf.bot_management.score lt 20)

Log mode

Log mode uses the AI Security Log Mode Ruleset — a pre-built ruleset that logs the full request body alongside detection results. This mode is designed for evaluation and tuning rather than production enforcement.

In log mode:

When to use log mode:

Enable log mode

  1. In the Cloudflare dashboard, go to the Security Settings page.

    Go to Settings ↗
  2. Under AI Security for Apps, find the Managed Ruleset section.

  3. Enable the AI Security Log Mode Ruleset.

  4. Set the action to Log.

  5. (Recommended) Configure payload logging so you can decrypt and view the full prompt content alongside detection results.

Deploy the managed ruleset using a PUT request:

Required API token permissions

At least one of the following token permissions is required:
  • Zone WAF Write
  • Account WAF Write
Update a zone entry point ruleset
curl "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/rulesets/phases/http_request_firewall_managed/entrypoint" \
	--request PUT \
	--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
	--json '{
		"rules": [
				{
						"action": "execute",
						"action_parameters": {
								"id": "b7cd52df92f74c848cec0c2ed385e336"
						},
						"expression": "true"
				}
		]
	}'

The ID of the AI Security Log Mode Ruleset is .

To set individual rule actions to log, override the rules within the managed ruleset using action_parameters.overrides. For more information, refer to Override a managed ruleset.

  1. Start in log mode. Enable the AI Security Log Mode Ruleset with the action set to Log. Configure payload logging so you can view prompts alongside detection results.

  2. Review detections in Security Analytics. Filter on events from the managed ruleset. Decrypt payloads and review the prompts that triggered detections. Note the scores to understand where to set thresholds.

  3. Build production rules. Based on your analysis, create custom rules with appropriate score thresholds and PII category filters.

  4. Disable log mode. Once your production rules are deployed and validated, disable the managed ruleset or keep it on Log as ongoing monitoring.

  5. Monitor and iterate. Continuously review detection events in Security Analytics and adjust thresholds as your traffic patterns evolve.