{"id":1497,"date":"2020-06-07T21:31:47","date_gmt":"2020-06-07T13:31:47","guid":{"rendered":"https:\/\/www.wesbytes.com\/guide\/?post_type=kb&#038;p=1497"},"modified":"2026-01-12T14:48:48","modified_gmt":"2026-01-12T06:48:48","slug":"adding-the-cf-ray-header-to-your-logs","status":"publish","type":"kb","link":"https:\/\/www.servergigabit.com\/guide\/kb\/adding-the-cf-ray-header-to-your-logs","title":{"rendered":"Step-by-step to Add the CF-RAY header to your logs"},"content":{"rendered":"<h4><img fetchpriority=\"high\" decoding=\"async\" class=\"alignnone\" src=\"https:\/\/developers.cloudflare.com\/core-services-preview.png\" alt=\"CF-RAY header\" width=\"1800\" height=\"1013\" \/><\/h4>\n<h4><strong>Adding the CF-RAY header to your logs<\/strong><\/h4>\n<p>The\u00a0<strong>CF-RAY\u00a0<\/strong>header\u00a0is added to help with tracing a request to a website through Cloudflare\u2019s network. You can use the ID when working with <a href=\"https:\/\/www.cloudflare.com\/\" rel=\"nofollow noopener\" target=\"_blank\">Cloudflare <\/a>Support to help troubleshoot any related issues you may have with connectivity. At the same time, you can reveal this\u00a0<strong>\u201cRay ID\u201d\u00a0<\/strong>in your logs by making some edits to configuration files in Apache and Nginx.<\/p>\n<p>&nbsp;<\/p>\n<p>For Apache:<\/p>\n<pre>LogFormat \"%h %l %u %t \\\"%r\\\" %&gt;s %b \\\"%{Referer}i\\\" \\\"%{User-agent}i\\\" %{CF-Ray}i\" cf_custom\r\nCustomLog log\/access_log cf_custom<\/pre>\n<p>For nginx:<\/p>\n<pre>log_format cf_custom '$remote_addr - $remote_user [$time_local] \u00a0'\r\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 '\"$request\" $status $body_bytes_sent '\r\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 '\"$http_referer\" \"$http_user_agent\" '\r\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 '$http_cf_ray';\r\n\r\naccess_log \u00a0\/var\/log\/nginx\/access.log cf_custom;<\/pre>\n<p>&nbsp;<\/p>\n<p><span data-sheets-root=\"1\">Please refer to the following article to know more.<br \/>\nKnowledge Base: <a href=\"https:\/\/www.servergigabit.com\/guide\/kb\/how-does-cloudflare-work\">How does Cloudflare work?<\/a><\/span><\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Adding the CF-RAY header to your logs The\u00a0CF-RAY\u00a0header\u00a0is added to help with tracing a request to a website through Cloudflare\u2019s network. You can use the ID when working with Cloudflare Support to help troubleshoot any related issues you may have with connectivity. At the same time, you can reveal this\u00a0\u201cRay ID\u201d\u00a0in your logs by making some edits to configuration files&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"kbtopic":[43],"kbtag":[1461],"class_list":["post-1497","kb","type-kb","status-publish","hentry","kbtopic-cloudflare","kbtag-cf-ray-header"],"_links":{"self":[{"href":"https:\/\/www.servergigabit.com\/guide\/wp-json\/wp\/v2\/kb\/1497","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.servergigabit.com\/guide\/wp-json\/wp\/v2\/kb"}],"about":[{"href":"https:\/\/www.servergigabit.com\/guide\/wp-json\/wp\/v2\/types\/kb"}],"author":[{"embeddable":true,"href":"https:\/\/www.servergigabit.com\/guide\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.servergigabit.com\/guide\/wp-json\/wp\/v2\/comments?post=1497"}],"version-history":[{"count":4,"href":"https:\/\/www.servergigabit.com\/guide\/wp-json\/wp\/v2\/kb\/1497\/revisions"}],"predecessor-version":[{"id":6092,"href":"https:\/\/www.servergigabit.com\/guide\/wp-json\/wp\/v2\/kb\/1497\/revisions\/6092"}],"wp:attachment":[{"href":"https:\/\/www.servergigabit.com\/guide\/wp-json\/wp\/v2\/media?parent=1497"}],"wp:term":[{"taxonomy":"kbtopic","embeddable":true,"href":"https:\/\/www.servergigabit.com\/guide\/wp-json\/wp\/v2\/kbtopic?post=1497"},{"taxonomy":"kbtag","embeddable":true,"href":"https:\/\/www.servergigabit.com\/guide\/wp-json\/wp\/v2\/kbtag?post=1497"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}