配置格式

  1. error_log log_file log_level

配置示例

  1. error_log logs/error.log error

以下是一些总结:

  • 错误日志无法自定义日志格式,但是可以定义需要记录哪些错误等级的日志。
  • 错误等级有:debug, info, notice, warn, error, crit, alert, or emerg
  • 默认记录 error 等级的错误。
  • debug 错误等级对于排查线上问题比较有用。需要在安装时通过 --with-debug 选项进行开启。

    参考

  1. ngx_core_module.html#error_log
  2. 链接
  3. Configuring the Nginx Error Log and Access Log