Debian系统上的Nginx主要记录两种类型的日志:访问日志(access_log)和错误日志(error_log)。这些日志对于统计、系统服务排错和监控非常有帮助。
通过log_format
指令,可以自定义日志格式,以满足特定的需求。
例如,以下是一个自定义的日志格式示例:
log_format custom '$remote_addr - $remote_user [$time_local] ' '"$request" $status $body_bytes_sent ' '"$http_referer" "$http_user_agent" "$http_x_forwarded_for"';
使用这个自定义格式,可以通过以下命令应用到访问日志:
access_log /var/log/nginx/access.log custom;
访问日志和错误日志的配置通常在Nginx的配置文件nginx.conf
中的http
模块下进行。例如:
http {
access_log /var/log/nginx/access.log custom;
error_log /var/log/nginx/error.log;
...
}
亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>