nginx 自定义日志格式输出

修改 nginx.conf

自定义日志格式、路径

log_format my_format '$remote_addr $msec $http_host $request_uri';

使用精准配准,对/log.jpg的请求记录自定义日志。

location =/log.jpg {
      default_type images/jpg;
      access_log  mylog.log my_format;
}

#nginx reload

./sbin/nginx -s reload

查看日志文件 

模拟请求

查看日志内容

日志格式化、内部变量查看地址。

https://nginx.org/en/docs/http/ngx_http_log_module.html#log_format

https://nginx.org/en/docs/http/ngx_http_core_module.html#variables

猜你喜欢

转载自blog.csdn.net/lw112190/article/details/110634495