Mugen
Mugen

Reputation: 9095

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?

Upvotes: 6

Views: 6641

Answers (1)

Andrea Golin
Andrea Golin

Reputation: 3559

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

Upvotes: 7

Related Questions