Reputation: 405
I'm running the nginx 1.4.2 web server on a few of my servers and have noticed that all of the HTTP 401, 404 and 500 responses are being logged to the access log file instead of the error log file.
Is there some way to configure nginx to log HTTP 401, 404 and 500 responses to the error log instead?
Upvotes: 3
Views: 2415
Reputation: 1305
If you dont modify nginx source or develop 3rd nginx module, there is no way to do this.
You should know that error_log
message is hard coded into nginx source or 3rd nginx module.
error_log
is information which helps you know what nginx did.
An example in nginx source is as following:
ngx_log_error(NGX_LOG_INFO, c->log, 0, "client sent too large request");
And access_log
message is a record of one http request.
So it is best not to put access_log
and error_log
in the same file.
BTW, it is a good idea to develop a 3rd module which can log requests to different file according to response status.
Upvotes: 1