Have nginx access_log and error_log log to STDOUT and STDERR of master process

后端 未结 6 2067
一整个雨季
一整个雨季 2020-12-12 10:18

Is there a way to have the master process log to STDOUT STDERR instead of to a file?

It seems that you can only pass a filepath to the access_log directive:

6条回答
  •  青春惊慌失措
    2020-12-12 11:08

    Edit: it seems nginx now supports error_log stderr; as mentioned in Anon's answer.

    You can send the logs to /dev/stdout. In nginx.conf:

    daemon off;
    error_log /dev/stdout info;
    
    http {
      access_log /dev/stdout;
      ...
    }
    

    edit: May need to run ln -sf /proc/self/fd /dev/ if using running certain docker containers, then use /dev/fd/1 or /dev/fd/2

提交回复
热议问题