title: Nginx conditional logging doesn't work
body: <p>I'm trying to write the body of the POST request to log file (access_400.log)  only when status 400 is received but the log file remains empty (It is created but empty). I can see in access.log the error.</p>
  
  <pre><code>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
  
  }
  </code></pre>