我尝试将POST请求的主体写入日志文件(access_400.log),仅在收到状态400但日志文件保持为空(已创建但为空)时。我可以在access.log中看到错误。
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
port_in_redirect off;
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $request_length $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
log_format full '$remote_addr - $remote_user [$time_local] "$request" '
'$status $request_length $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for" [$request_body]';
map $status $anyerr {
~^[45] 1;
default 0;
}
access_log /var/log/nginx/access.log main;
access_log /var/log/nginx/access_400.log full if=$anyerr;
sendfile on;
keepalive_timeout 65;
"/etc/nginx/nginx.conf" 62L, 1873C 52,5 52%
# Elastic Beanstalk Modification(EB_INCLUDE)
log_format healthd '$msec"$uri"'
'$status"$request_time"$upstream_response_time"'
'$http_x_forwarded_for';
include /etc/nginx/conf.d/*.conf;
# End Modification
}
答案 0 :(得分:0)
access_log /var/log/nginx/access_400.log full if=$anyerr;
应该是服务器的孩子,而不是 http