nginx access_log 的“main”参数是什么?

lon*_*nix 10 nginx

在许多 nginx 配置教程中,我看到了这一点:

access_log /var/log/nginx/access.log main
Run Code Online (Sandbox Code Playgroud)

什么是main?它在文档中找不到。

Ric*_*ith 9

access_log指令的第二个参数是一个可选format名称,它决定了日志文件条目的内容。

默认格式为combined,预定义为:

log_format combined '$remote_addr - $remote_user [$time_local] '
                    '"$request" $status $body_bytes_sent '
                    '"$http_referer" "$http_user_agent"';
Run Code Online (Sandbox Code Playgroud)

有关详细信息,请参阅此文档

命名的格式main应该由log_formatNginx 配置中其他地方的指令定义。使用命令nginx -T(带大写T)查看所有包含文件的整个 Nginx 配置。