在nginx配置文件中,可以使用变量 "$msec" 来表示当前的时间戳,它是一个十位数的时间戳(单位为秒)。你可以在需要的地方使用该变量来表示时间戳。

以下是一个示例:

location / {
    log_format mylog \"$remote_addr - $remote_user [$time_local] \"\"$request\"\" '
                    \"$status $body_bytes_sent \"\"$http_referer\"\" '
                    \"\"$http_user_agent\"\" $msec\"';

    access_log /var/log/nginx/access.log mylog;
}

在上述示例中,"$msec" 变量被用于自定义日志格式 "mylog" 中的 "$msec" 字段。日志文件 "/var/log/nginx/access.log" 将记录每个请求的时间戳。

Nginx 配置文件获取10位时间戳 - $msec 变量使用指南

原文地址: https://www.cveoy.top/t/topic/qffC 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录