访问日志(access_log

需要设置 format:

  1. access_log /var/log/nginx/access.log main;
  2. log_format main '$remote_addr - $remote_user [$time_local] "$request" '
  3. '$status $body_bytes_sent "$http_referer" '
  4. '"$http_user_agent" "$http_x_forwarded_for"';

错误日志(error_log

需要设置 级别:

  1. error_log /var/log/nginx/error.log warn;

级别按严重程度分:debuginfonoticewarnerrorcritalertemerg,只有等于或高于此级别才会写入错误日志中。

日志切割

https://wsgzao.github.io/post/logrotate/
https://wiki.threatbook-inc.cn/pages/viewpage.action?pageId=7637018