以下の内容はhttps://ryuichi1208.hateblo.jp/entry/2025/04/10/000000より取得しました。


【Nginx】リクエストの処理開始時刻をログに出す

Nginxでリクエストの処理開始時刻をログに出力するためには、ngx_luaモジュールを使用して、リクエストの処理開始時刻を取得し、ログフォーマットに追加することができます。以下はその実現方法の例です。

http {
    lua_package_path '/path/to/lua/?.lua;;';  # Luaのパスを設定

    log_format main '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for" '
                      '[Request Start: $request_time]';  # 追加: 処理開始時刻をログに

    access_log /var/log/nginx/access.log main;

    server {
        listen 80;
        server_name localhost;

        location / {
            set_by_lua $request_time_start 'return ngx.now()';  # リクエストの開始時刻をセット
            access_by_lua_block {
                -- 開始時刻の取得
                ngx.var.request_time_start = ngx.now()
            }

            # 他の設定
        }
    }
}



以上の内容はhttps://ryuichi1208.hateblo.jp/entry/2025/04/10/000000より取得しました。
このページはhttp://font.textar.tv/のウェブフォントを使用してます

不具合報告/要望等はこちらへお願いします。
モバイルやる夫Viewer Ver0.14