title: Nginx log to stderr
body: <p>I want to redirect nginx access logs to <code>stdout</code> to be able to analyze them through <code>journalctl</code> (systemd). </p>
  
  <p>There is the same question with approved answer.
  <a href="https://stackoverflow.com/questions/22541333/have-nginx-access-log-and-error-log-log-to-stdout-and-stderr-of-master-process">Have nginx access_log and error_log log to STDOUT and STDERR of master process</a>
  But it does not work for me. With <code>/dev/stderr</code> I get <code>open() "/dev/stderr" failed (6: No such device or address)</code>. With <code>/dev/stdout</code> I get no access logs in <code>journalctl -u nginx</code>.</p>
  
  <p>nginx.conf</p>
  
  <pre><code>daemon off;
  
  http {
      access_log /dev/stdout;
      error_log /dev/stdout;
      ...
  }
  ...
  </code></pre>
  
  <p>sitename.conf</p>
  
  <pre><code>server {
      server_name sitename.com;
      root /home/username/sitename.com;
  
      location / {
          proxy_pass http://localhost:3000/;
          proxy_set_header Host $host;
          proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
          access_log on;
      }
  }
  </code></pre>
  
  <p>nginx.service</p>
  
  <pre><code>[Service]
  Type=forking
  PIDFile=/run/nginx.pid
  StandardOutput=syslog
  StandardError=syslog
  SyslogIdentifier=nginx
  ExecStartPre=/usr/sbin/nginx -t -q -g 'master_process on;'
  ExecStart=/usr/sbin/nginx -g 'master_process on;'
  ExecReload=/usr/sbin/nginx -g 'master_process on;' -s reload
  ExecStop=-/sbin/start-stop-daemon --quiet --stop --retry QUIT/5 --pidfile /run/nginx.pid
  TimeoutStopSec=5
  </code></pre>
  
  <p>I've tried my best to workaround that by changing every possible parameter in the code above and with different nginx versions (1.2, 1.6) but without any success.</p>
  
  <p>I'm really, really interested how to make this work so I raise this question again on a different thread as I consider previous answer is wrong, speculative or environment specific.</p>
  
  <pre><code>$ journalctl -u nginx
  </code></pre>
  
  <p>contains only lines like </p>
  
  <pre><code> Feb 08 13:05:23 Username systemd[1]: Started A high performance web server and a reverse proxy server.
  </code></pre>
  
  <p>and no sign of access logs :(</p>