How to write in access.log only logs with 200 status and all the rest in error.log?

use the ispmanager control panel 5. (ubuntu 14 + nginx+php-fpm, php 5). recently put on a new server the same ispmanager 5 + 16 ubuntu and php 7. revealed this problem: for some reason the logs of the treatment sites in most cases were written in access.log.

Let me explain. If earlier on the old server, let's say the 401 is always written in error.log, now, such errors are written in access.log. How to change this? And preferably just leave it in access.log only a specific status (for example, 200, 301, 302 etc)
July 2nd 19 at 17:09
2 answers
July 2nd 19 at 17:11
Solution
It does not answer the question.

Don't do like you want.
Error log exists for the cloning errors that you must correct and to prevent re-occurrence.

The Access log is intended for logging of all responses from the server worked WITHOUT errors. 404, 301/302, etc is valid from the point of view of web server responses and their is no need to classify erroneous.

You would be better to use the tools to work with logs, in order to work with access.log and filter only the desired messages. There are tools, from grep to ELK.
Yes, but why before 401 came in error.log, but now is not? for me it was very convenient to see from the panel itself, and not to put analyzers that now probably will have to do.
in addition to not-so-important 401 error found on the new server in access logs 499 error, but this is much more serious - Stephany.Gusikowski85 commented on July 2nd 19 at 17:14
July 2nd 19 at 17:13
Solution
If you leave out a why you need it, the solution is simple enough:
map $status $loggable {
 ~^[2] 200.log;
 default default.log;
}
 server {
 listen 80;

 access_log /var/log/nginx/$loggable main;

 location / {
 root /usr/share/nginx/html;
}
}

That is, we simply look Marie status and depending on this substitute variable, which then apolloim when writing the log.
thank you. and it is possible without changing the specific configs for specific sites, where the path for logs is registered, a chance to ask all domains on the server such parameters, and that they were more important than specific configs?

it I to that if on the old server 401 error written to the error log and now is written in access - so somewhere it is written - Stephany.Gusikowski85 commented on July 2nd 19 at 17:16
Yes, access_log directives there are several execution contexts, just set it on the http level - Stephany.Gusikowski85 commented on July 2nd 19 at 17:19

Find more questions by tags Nginx