<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>無狀態 - 東東 GCP 教學 - GCP 實戰講師</title>
	<atom:link href="https://dongdonggcp.com/tag/%E7%84%A1%E7%8B%80%E6%85%8B/feed/" rel="self" type="application/rss+xml" />
	<link>https://dongdonggcp.com</link>
	<description>助你考取證照，轉職成功</description>
	<lastBuildDate>Mon, 17 Jun 2024 13:20:12 +0000</lastBuildDate>
	<language>zh-TW</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://dongdonggcp.com/wp-content/uploads/2025/04/cropped-340838097_121391010914395_5443948698124160121_n-32x32.jpg</url>
	<title>無狀態 - 東東 GCP 教學 - GCP 實戰講師</title>
	<link>https://dongdonggcp.com</link>
	<width>32</width>
	<height>32</height>
</image> 
<site xmlns="com-wordpress:feed-additions:1">243235092</site>	<item>
		<title>[Cloud Run 教學] 如何收集在 Cloud Run 上運作的 Nginx Log？寫入 Cloud Logging</title>
		<link>https://dongdonggcp.com/2024/06/17/how-to-write-cloud-run-nginx-log-to-cloud-logging/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=how-to-write-cloud-run-nginx-log-to-cloud-logging</link>
					<comments>https://dongdonggcp.com/2024/06/17/how-to-write-cloud-run-nginx-log-to-cloud-logging/#respond</comments>
		
		<dc:creator><![CDATA[東東]]></dc:creator>
		<pubDate>Mon, 17 Jun 2024 13:20:12 +0000</pubDate>
				<category><![CDATA[Google Cloud Platform]]></category>
		<category><![CDATA[Artifact Registry]]></category>
		<category><![CDATA[Cloud Logging]]></category>
		<category><![CDATA[Cloud Run]]></category>
		<category><![CDATA[Log]]></category>
		<category><![CDATA[Nginx]]></category>
		<category><![CDATA[容器]]></category>
		<category><![CDATA[無伺服器]]></category>
		<category><![CDATA[無狀態]]></category>
		<guid isPermaLink="false">https://dongdonggcp.com/?p=6499</guid>

					<description><![CDATA[<p>Cloud Run 是無狀態的， 代表它 [&#8230;]</p>
<p>The post <a href="https://dongdonggcp.com/2024/06/17/how-to-write-cloud-run-nginx-log-to-cloud-logging/">[Cloud Run 教學] 如何收集在 Cloud Run 上運作的 Nginx Log？寫入 Cloud Logging</a> first appeared on <a href="https://dongdonggcp.com">東東 GCP 教學 - GCP 實戰講師</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>Cloud Run 是無狀態的，</p>



<p>代表它的容器重啟之後，</p>



<p>容器裡面的 Log 全部消失不見，徹底的無狀態。</p>



<p>那我們如果想要除錯，只能看到 Cloud Run 本身的 Log，</p>



<p>怕資訊不足，怎麼辦？</p>



<p>你又不能直接連進去 Container，</p>



<p>因為它又是「無伺服器」的，根本不能連到它 Command Line。</p>



<p>怎麼辦呢？</p>



<p></p>



<p>其實它是可以設定輸出 Log 的位置的，</p>



<p>這裡做一個簡單的範例給大家參考～</p>



<div style="height:15px" aria-hidden="true" class="wp-block-spacer"></div>



<p>我先在 Cloud Shel l 開一個目錄</p>



<p>mkdir nginx</p>



<p>cd nginx</p>



<p>mkdir write-to-logging</p>



<p>cd write-to-logging</p>



<figure class="wp-block-image size-large"><img fetchpriority="high" decoding="async" width="1144" height="144" src="https://dongdonggcp.com/wp-content/uploads/2024/06/e688aae59c96-2024-06-17-e4b88be58d888.30.31.png?w=1024" alt="" class="wp-image-6502" srcset="https://dongdonggcp.com/wp-content/uploads/2024/06/e688aae59c96-2024-06-17-e4b88be58d888.30.31.png 1144w, https://dongdonggcp.com/wp-content/uploads/2024/06/e688aae59c96-2024-06-17-e4b88be58d888.30.31-300x38.png 300w, https://dongdonggcp.com/wp-content/uploads/2024/06/e688aae59c96-2024-06-17-e4b88be58d888.30.31-1024x129.png 1024w, https://dongdonggcp.com/wp-content/uploads/2024/06/e688aae59c96-2024-06-17-e4b88be58d888.30.31-768x97.png 768w" sizes="(max-width: 1144px) 100vw, 1144px" /></figure>



<p>在資料夾裡建立3個檔案，各位直接複製貼上就好了：</p>



<p>第一個 index.html 首頁檔案</p>



<p>vim index.html</p>



<pre class="wp-block-code"><code>&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;head&gt;
    &lt;title&gt;Welcome to Nginx!&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
    &lt;h1&gt;Success! Dongdong Nginx server is running!&lt;/h1&gt;
&lt;/body&gt;
&lt;/html&gt;</code></pre>



<p>截圖</p>



<figure class="wp-block-image size-large"><img decoding="async" width="1300" height="304" src="https://dongdonggcp.com/wp-content/uploads/2024/06/e688aae59c96-2024-06-17-e4b88be58d888.34.08.png?w=1024" alt="" class="wp-image-6504" srcset="https://dongdonggcp.com/wp-content/uploads/2024/06/e688aae59c96-2024-06-17-e4b88be58d888.34.08.png 1300w, https://dongdonggcp.com/wp-content/uploads/2024/06/e688aae59c96-2024-06-17-e4b88be58d888.34.08-300x70.png 300w, https://dongdonggcp.com/wp-content/uploads/2024/06/e688aae59c96-2024-06-17-e4b88be58d888.34.08-1024x239.png 1024w, https://dongdonggcp.com/wp-content/uploads/2024/06/e688aae59c96-2024-06-17-e4b88be58d888.34.08-768x180.png 768w" sizes="(max-width: 1300px) 100vw, 1300px" /></figure>



<div style="height:15px" aria-hidden="true" class="wp-block-spacer"></div>



<p>第二個是 Nginx 的設定檔 </p>



<p>vim nginx.conf</p>



<p>重點是設定 Nginx 把日志寫到 stdout 和 stderr，</p>



<p>然後讓 Cloud Run 自動收集這些 Log 並傳送到 Cloud Logging。</p>



<pre class="wp-block-code"><code>worker_processes  1;

events {
    worker_connections  1024;
}

http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;

<strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-tertiary-color">    access_log /dev/stdout;
    error_log /dev/stderr;</mark></strong>

    server {
        listen       8080;
        server_name  localhost;

        location / {
            root   /usr/share/nginx/html;
            index  index.html index.htm;
        }

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   /usr/share/nginx/html;
        }
    }
}</code></pre>



<p>截圖</p>



<figure class="wp-block-image size-large"><img decoding="async" width="794" height="912" src="https://dongdonggcp.com/wp-content/uploads/2024/06/e688aae59c96-2024-06-17-e4b88be58d888.34.48.png?w=794" alt="" class="wp-image-6506" srcset="https://dongdonggcp.com/wp-content/uploads/2024/06/e688aae59c96-2024-06-17-e4b88be58d888.34.48.png 794w, https://dongdonggcp.com/wp-content/uploads/2024/06/e688aae59c96-2024-06-17-e4b88be58d888.34.48-261x300.png 261w, https://dongdonggcp.com/wp-content/uploads/2024/06/e688aae59c96-2024-06-17-e4b88be58d888.34.48-768x882.png 768w" sizes="(max-width: 794px) 100vw, 794px" /></figure>



<div style="height:15px" aria-hidden="true" class="wp-block-spacer"></div>



<p>第三個是 Dockerfile</p>



<p>vim Dockerfile</p>



<pre class="wp-block-code"><code># Use the official Nginx image from the Docker Hub
FROM nginx:latest

# Copy the Nginx configuration file
COPY nginx.conf /etc/nginx/nginx.conf

# Copy the index.html file to the default Nginx directory
COPY index.html /usr/share/nginx/html/index.html

# Expose the port that Cloud Run will use
EXPOSE 8080

# Start Nginx when the container launches
CMD &#091;"nginx", "-g", "daemon off;"]</code></pre>



<p></p>



<p>我在自己專案的 Artifact Registry 建立 Repository 為 nginx</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1511" height="556" src="https://dongdonggcp.com/wp-content/uploads/2024/06/e688aae59c96-2024-06-17-e4b88be58d888.42.44-1.png?w=1024" alt="" class="wp-image-6510" srcset="https://dongdonggcp.com/wp-content/uploads/2024/06/e688aae59c96-2024-06-17-e4b88be58d888.42.44-1.png 1511w, https://dongdonggcp.com/wp-content/uploads/2024/06/e688aae59c96-2024-06-17-e4b88be58d888.42.44-1-300x110.png 300w, https://dongdonggcp.com/wp-content/uploads/2024/06/e688aae59c96-2024-06-17-e4b88be58d888.42.44-1-1024x377.png 1024w, https://dongdonggcp.com/wp-content/uploads/2024/06/e688aae59c96-2024-06-17-e4b88be58d888.42.44-1-768x283.png 768w" sizes="(max-width: 1511px) 100vw, 1511px" /></figure>



<p>然後在 Cloud Shel l 建立 Docker Image 名字叫 write-to-logging </p>



<p>(dong-dong-gcp-3 請改成你的專案 ID 喔)</p>



<p>(注意下面指令有一個句號喔)</p>



<p>docker build -t asia-east1-docker.pkg.dev/dong-dong-gcp-3/nginx/write-to-logging .</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="2470" height="634" src="https://dongdonggcp.com/wp-content/uploads/2024/06/e688aae59c96-2024-06-17-e4b88be58d888.45.36.png?w=1024" alt="" class="wp-image-6511" srcset="https://dongdonggcp.com/wp-content/uploads/2024/06/e688aae59c96-2024-06-17-e4b88be58d888.45.36.png 2470w, https://dongdonggcp.com/wp-content/uploads/2024/06/e688aae59c96-2024-06-17-e4b88be58d888.45.36-300x77.png 300w, https://dongdonggcp.com/wp-content/uploads/2024/06/e688aae59c96-2024-06-17-e4b88be58d888.45.36-1024x263.png 1024w, https://dongdonggcp.com/wp-content/uploads/2024/06/e688aae59c96-2024-06-17-e4b88be58d888.45.36-768x197.png 768w, https://dongdonggcp.com/wp-content/uploads/2024/06/e688aae59c96-2024-06-17-e4b88be58d888.45.36-1536x394.png 1536w, https://dongdonggcp.com/wp-content/uploads/2024/06/e688aae59c96-2024-06-17-e4b88be58d888.45.36-2048x526.png 2048w" sizes="(max-width: 2470px) 100vw, 2470px" /></figure>



<div style="height:15px" aria-hidden="true" class="wp-block-spacer"></div>



<p>接下來就把 Image Push 到 Artifact Registry</p>



<p>docker push asia-east1-docker.pkg.dev/dong-dong-gcp-3/nginx/write-to-logging</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="2282" height="428" src="https://dongdonggcp.com/wp-content/uploads/2024/06/e688aae59c96-2024-06-17-e4b88be58d888.46.57.png?w=1024" alt="" class="wp-image-6514" srcset="https://dongdonggcp.com/wp-content/uploads/2024/06/e688aae59c96-2024-06-17-e4b88be58d888.46.57.png 2282w, https://dongdonggcp.com/wp-content/uploads/2024/06/e688aae59c96-2024-06-17-e4b88be58d888.46.57-300x56.png 300w, https://dongdonggcp.com/wp-content/uploads/2024/06/e688aae59c96-2024-06-17-e4b88be58d888.46.57-1024x192.png 1024w, https://dongdonggcp.com/wp-content/uploads/2024/06/e688aae59c96-2024-06-17-e4b88be58d888.46.57-768x144.png 768w, https://dongdonggcp.com/wp-content/uploads/2024/06/e688aae59c96-2024-06-17-e4b88be58d888.46.57-1536x288.png 1536w, https://dongdonggcp.com/wp-content/uploads/2024/06/e688aae59c96-2024-06-17-e4b88be58d888.46.57-2048x384.png 2048w" sizes="(max-width: 2282px) 100vw, 2282px" /></figure>



<p></p>



<p>接下來就看到 nginx 這個 repo 有一個新的 Image</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1804" height="806" src="https://dongdonggcp.com/wp-content/uploads/2024/06/e688aae59c96-2024-06-17-e4b88be58d888.47.15.png?w=1024" alt="" class="wp-image-6515" srcset="https://dongdonggcp.com/wp-content/uploads/2024/06/e688aae59c96-2024-06-17-e4b88be58d888.47.15.png 1804w, https://dongdonggcp.com/wp-content/uploads/2024/06/e688aae59c96-2024-06-17-e4b88be58d888.47.15-300x134.png 300w, https://dongdonggcp.com/wp-content/uploads/2024/06/e688aae59c96-2024-06-17-e4b88be58d888.47.15-1024x458.png 1024w, https://dongdonggcp.com/wp-content/uploads/2024/06/e688aae59c96-2024-06-17-e4b88be58d888.47.15-768x343.png 768w, https://dongdonggcp.com/wp-content/uploads/2024/06/e688aae59c96-2024-06-17-e4b88be58d888.47.15-1536x686.png 1536w" sizes="(max-width: 1804px) 100vw, 1804px" /></figure>



<div style="height:15px" aria-hidden="true" class="wp-block-spacer"></div>



<p>如果都沒問題的話，就可以部署到 Cloud Run，</p>



<p>如果懶得在 Console 上點，可以直接複製下面的指令 (記得改掉 Project ID 喔 )：</p>



<p>gcloud run deploy nginx-logging \<br>&#8211;image asia-east1-docker.pkg.dev/dong-dong-gcp-3/nginx/write-to-logging \<br>&#8211;platform managed \<br>&#8211;region asia-east1 \<br>&#8211;allow-unauthenticated</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1820" height="440" src="https://dongdonggcp.com/wp-content/uploads/2024/06/e688aae59c96-2024-06-17-e4b88be58d888.50.07.png?w=1024" alt="" class="wp-image-6518" srcset="https://dongdonggcp.com/wp-content/uploads/2024/06/e688aae59c96-2024-06-17-e4b88be58d888.50.07.png 1820w, https://dongdonggcp.com/wp-content/uploads/2024/06/e688aae59c96-2024-06-17-e4b88be58d888.50.07-300x73.png 300w, https://dongdonggcp.com/wp-content/uploads/2024/06/e688aae59c96-2024-06-17-e4b88be58d888.50.07-1024x248.png 1024w, https://dongdonggcp.com/wp-content/uploads/2024/06/e688aae59c96-2024-06-17-e4b88be58d888.50.07-768x186.png 768w, https://dongdonggcp.com/wp-content/uploads/2024/06/e688aae59c96-2024-06-17-e4b88be58d888.50.07-1536x371.png 1536w" sizes="(max-width: 1820px) 100vw, 1820px" /></figure>



<p>其實我本來就部署成功了，</p>



<p>但我再輸入部署指令時，它不會報錯，</p>



<p>只會幫我增加最新的版本，蠻貼心的。</p>



<p>接下來看一下 Cloud Run 的 Console：</p>



<p>那個 nginx-logging 就是我剛部署的服務，點 &#8220;nginx-logging&#8221; 看看</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1396" height="712" src="https://dongdonggcp.com/wp-content/uploads/2024/06/e688aae59c96-2024-06-17-e4b88be58d888.51.41.png?w=1024" alt="" class="wp-image-6520" srcset="https://dongdonggcp.com/wp-content/uploads/2024/06/e688aae59c96-2024-06-17-e4b88be58d888.51.41.png 1396w, https://dongdonggcp.com/wp-content/uploads/2024/06/e688aae59c96-2024-06-17-e4b88be58d888.51.41-300x153.png 300w, https://dongdonggcp.com/wp-content/uploads/2024/06/e688aae59c96-2024-06-17-e4b88be58d888.51.41-1024x522.png 1024w, https://dongdonggcp.com/wp-content/uploads/2024/06/e688aae59c96-2024-06-17-e4b88be58d888.51.41-768x392.png 768w" sizes="(max-width: 1396px) 100vw, 1396px" /></figure>



<p>再點開它的超連結</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1410" height="718" src="https://dongdonggcp.com/wp-content/uploads/2024/06/e688aae59c96-2024-06-17-e4b88be58d888.52.32.png?w=1024" alt="" class="wp-image-6521" srcset="https://dongdonggcp.com/wp-content/uploads/2024/06/e688aae59c96-2024-06-17-e4b88be58d888.52.32.png 1410w, https://dongdonggcp.com/wp-content/uploads/2024/06/e688aae59c96-2024-06-17-e4b88be58d888.52.32-300x153.png 300w, https://dongdonggcp.com/wp-content/uploads/2024/06/e688aae59c96-2024-06-17-e4b88be58d888.52.32-1024x521.png 1024w, https://dongdonggcp.com/wp-content/uploads/2024/06/e688aae59c96-2024-06-17-e4b88be58d888.52.32-768x391.png 768w" sizes="(max-width: 1410px) 100vw, 1410px" /></figure>



<p>會看到</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1464" height="390" src="https://dongdonggcp.com/wp-content/uploads/2024/06/e688aae59c96-2024-06-17-e4b88be58d888.53.44.png?w=1024" alt="" class="wp-image-6523" srcset="https://dongdonggcp.com/wp-content/uploads/2024/06/e688aae59c96-2024-06-17-e4b88be58d888.53.44.png 1464w, https://dongdonggcp.com/wp-content/uploads/2024/06/e688aae59c96-2024-06-17-e4b88be58d888.53.44-300x80.png 300w, https://dongdonggcp.com/wp-content/uploads/2024/06/e688aae59c96-2024-06-17-e4b88be58d888.53.44-1024x273.png 1024w, https://dongdonggcp.com/wp-content/uploads/2024/06/e688aae59c96-2024-06-17-e4b88be58d888.53.44-768x205.png 768w" sizes="(max-width: 1464px) 100vw, 1464px" /></figure>



<p>代表部署成功了！</p>



<p>那要怎麼證明，它的 Log 有寫入 Cloud Logging 呢？</p>



<p>我們先故意在網址列尾巴增加 &#8220;?&#8221; 和其他英文數字</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1334" height="502" src="https://dongdonggcp.com/wp-content/uploads/2024/06/e688aae59c96-2024-06-17-e4b88be58d888.54.37-1.png?w=1024" alt="" class="wp-image-6534" srcset="https://dongdonggcp.com/wp-content/uploads/2024/06/e688aae59c96-2024-06-17-e4b88be58d888.54.37-1.png 1334w, https://dongdonggcp.com/wp-content/uploads/2024/06/e688aae59c96-2024-06-17-e4b88be58d888.54.37-1-300x113.png 300w, https://dongdonggcp.com/wp-content/uploads/2024/06/e688aae59c96-2024-06-17-e4b88be58d888.54.37-1-1024x385.png 1024w, https://dongdonggcp.com/wp-content/uploads/2024/06/e688aae59c96-2024-06-17-e4b88be58d888.54.37-1-768x289.png 768w" sizes="(max-width: 1334px) 100vw, 1334px" /></figure>



<p>然後按 Enter，它顯示畫面是不變的，</p>



<p>但是這個網址會記錄到 Nginx 的 Log 裡面。</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1428" height="378" src="https://dongdonggcp.com/wp-content/uploads/2024/06/e688aae59c96-2024-06-17-e4b88be58d888.54.50-1.png?w=1024" alt="" class="wp-image-6536" srcset="https://dongdonggcp.com/wp-content/uploads/2024/06/e688aae59c96-2024-06-17-e4b88be58d888.54.50-1.png 1428w, https://dongdonggcp.com/wp-content/uploads/2024/06/e688aae59c96-2024-06-17-e4b88be58d888.54.50-1-300x79.png 300w, https://dongdonggcp.com/wp-content/uploads/2024/06/e688aae59c96-2024-06-17-e4b88be58d888.54.50-1-1024x271.png 1024w, https://dongdonggcp.com/wp-content/uploads/2024/06/e688aae59c96-2024-06-17-e4b88be58d888.54.50-1-768x203.png 768w" sizes="(max-width: 1428px) 100vw, 1428px" /></figure>



<p>你可以點開它的 Log 查看</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1750" height="1010" src="https://dongdonggcp.com/wp-content/uploads/2024/06/e688aae59c96-2024-06-17-e4b88be58d888.55.59.png?w=1024" alt="" class="wp-image-6529" srcset="https://dongdonggcp.com/wp-content/uploads/2024/06/e688aae59c96-2024-06-17-e4b88be58d888.55.59.png 1750w, https://dongdonggcp.com/wp-content/uploads/2024/06/e688aae59c96-2024-06-17-e4b88be58d888.55.59-300x173.png 300w, https://dongdonggcp.com/wp-content/uploads/2024/06/e688aae59c96-2024-06-17-e4b88be58d888.55.59-1024x591.png 1024w, https://dongdonggcp.com/wp-content/uploads/2024/06/e688aae59c96-2024-06-17-e4b88be58d888.55.59-768x443.png 768w, https://dongdonggcp.com/wp-content/uploads/2024/06/e688aae59c96-2024-06-17-e4b88be58d888.55.59-1536x886.png 1536w" sizes="(max-width: 1750px) 100vw, 1750px" /></figure>



<p>你會在左邊的 Log 欄位看到有 stdout 和 stderr 的選項，點擊篩選：</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="2176" height="888" src="https://dongdonggcp.com/wp-content/uploads/2024/06/e688aae59c96-2024-06-17-e4b88be58d889.01.08-2.png?w=1024" alt="" class="wp-image-6533" srcset="https://dongdonggcp.com/wp-content/uploads/2024/06/e688aae59c96-2024-06-17-e4b88be58d889.01.08-2.png 2176w, https://dongdonggcp.com/wp-content/uploads/2024/06/e688aae59c96-2024-06-17-e4b88be58d889.01.08-2-300x122.png 300w, https://dongdonggcp.com/wp-content/uploads/2024/06/e688aae59c96-2024-06-17-e4b88be58d889.01.08-2-1024x418.png 1024w, https://dongdonggcp.com/wp-content/uploads/2024/06/e688aae59c96-2024-06-17-e4b88be58d889.01.08-2-768x313.png 768w, https://dongdonggcp.com/wp-content/uploads/2024/06/e688aae59c96-2024-06-17-e4b88be58d889.01.08-2-1536x627.png 1536w, https://dongdonggcp.com/wp-content/uploads/2024/06/e688aae59c96-2024-06-17-e4b88be58d889.01.08-2-2048x836.png 2048w" sizes="(max-width: 2176px) 100vw, 2176px" /></figure>



<p>就可以看到 Nginx Container 寫到 Cloud Logging 的 Log 了！</p>



<p>現在看到是長這樣，這些都是 Cloud Run 本身沒有記錄的 Log 喔！</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="2570" height="720" src="https://dongdonggcp.com/wp-content/uploads/2024/06/e688aae59c96-2024-06-17-e4b88be58d889.06.44.png?w=1024" alt="" class="wp-image-6538" srcset="https://dongdonggcp.com/wp-content/uploads/2024/06/e688aae59c96-2024-06-17-e4b88be58d889.06.44.png 2570w, https://dongdonggcp.com/wp-content/uploads/2024/06/e688aae59c96-2024-06-17-e4b88be58d889.06.44-300x84.png 300w, https://dongdonggcp.com/wp-content/uploads/2024/06/e688aae59c96-2024-06-17-e4b88be58d889.06.44-1024x287.png 1024w, https://dongdonggcp.com/wp-content/uploads/2024/06/e688aae59c96-2024-06-17-e4b88be58d889.06.44-768x215.png 768w, https://dongdonggcp.com/wp-content/uploads/2024/06/e688aae59c96-2024-06-17-e4b88be58d889.06.44-1536x430.png 1536w, https://dongdonggcp.com/wp-content/uploads/2024/06/e688aae59c96-2024-06-17-e4b88be58d889.06.44-2048x574.png 2048w" sizes="(max-width: 2570px) 100vw, 2570px" /></figure>



<p>如果把篩選器移除，才會同時看到 Cloud Run 和 Nginx 本身收集到的 Log：</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1994" height="274" src="https://dongdonggcp.com/wp-content/uploads/2024/06/nginx-log.png?w=1024" alt="" class="wp-image-6540" srcset="https://dongdonggcp.com/wp-content/uploads/2024/06/nginx-log.png 1994w, https://dongdonggcp.com/wp-content/uploads/2024/06/nginx-log-300x41.png 300w, https://dongdonggcp.com/wp-content/uploads/2024/06/nginx-log-1024x141.png 1024w, https://dongdonggcp.com/wp-content/uploads/2024/06/nginx-log-768x106.png 768w, https://dongdonggcp.com/wp-content/uploads/2024/06/nginx-log-1536x211.png 1536w" sizes="(max-width: 1994px) 100vw, 1994px" /></figure>



<p>今天就簡單分享到這裡，謝謝大家！</p>



<p></p>



<p></p>



<p></p>



<p></p>



<p></p>



<p></p>



<p></p><p>The post <a href="https://dongdonggcp.com/2024/06/17/how-to-write-cloud-run-nginx-log-to-cloud-logging/">[Cloud Run 教學] 如何收集在 Cloud Run 上運作的 Nginx Log？寫入 Cloud Logging</a> first appeared on <a href="https://dongdonggcp.com">東東 GCP 教學 - GCP 實戰講師</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://dongdonggcp.com/2024/06/17/how-to-write-cloud-run-nginx-log-to-cloud-logging/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">6499</post-id>	</item>
	</channel>
</rss>
