How to turn off or specify the nginx error log location?

后端 未结 6 1343
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-01 11:09

I compiled the nginx on Ubuntu myself. I start my nginx with -c nginx.conf parameter. In my nginx.conf file, I try to turn off error log with but failed.

err         


        
6条回答
  •  再見小時候
    2021-01-01 11:53

    Per this post on the nginx.org mailing list (extract quoted below), the %%ERROR_LOG_PATH%% is set as a compile option, and checked immediately on startup, causing the "Could not open" alert. Specifying the prefix (with -p) may help suppress the alert, but only if the %%ERROR_LOG_PATH%% was specified as a relative path at compile time.

    You can check how it is specified in your current executable with

    nginx -V 2>&1 | grep -oE 'error-log-path=\S*'

    That is why the solution proposed by @Michael works for some, but not for others.

    See changelog:

    Changes with nginx 0.7.53

    ...

    *) Change: now a log set by --error-log-path is created from the very start-up.

    *) Feature: now the start up errors and warnings are outputted to an error_log and stderr.

    ...

    Now compiled in error_log value always used to log errors at start time (and emits warning if nginx can't open it). Once config file have been read - error_log from config will be used instead.

    If you have compiled nginx with error_log path relative to prefix - it should be possible to override startup error_log via -p switch.

    Maxim Dounin

提交回复
热议问题