nginxstdoutstderrnginx-config

Send nginx logs to both syslog and stdout/stderr


By default, my nginx server is plotting logs to stdout and stderr.

I want to forward logs to my syslog server, and I'm doing so successfully, from nginx.conf:

server {
  ...
  error_log syslog:server=localhost:5447,facility=local7,tag=nginx_client,severity=error;
  access_log syslog:server=localhost:5447,facility=local7,tag=nginx_client,severity=info;
  ...
}

How can I config my server to also plot the logs to stdout and stderr?


Solution

  • Just have multiple error_log and access_log entries inside your block

    error_log syslog:server=localhost:5447,facility=local7,tag=nginx_client,severity=error;
    
    access_log syslog:server=localhost:5447,facility=local7,tag=nginx_client,severity=info;
    
    error_log stderr;
    access_log /dev/stdout;
    

    Should do the trick