2017-01-08 6 views
0

NGINXの初心者はここにあります。nginx.confのlog_formatは無視されます

私のログが現在のように見える

92.21.236.47 - - [08 /月/ 2017:00:48:10 +0000] "GET/HTTP/1.1" 200 148 " - "「Mozillaの/5.0(Windows NTの10.0; WOW64; RV:50.0)のGecko/20100101 Firefoxの/ 50.0"

私は

log_format main '$remote_addr - $remote_user xxx[$time_local]xxx ' 
       '"$request" $status $body_bytes_sent ' 
       '"$http_referer" "$http_user_agent"'; 

access_log /var/log/nginx/access.log; 
error_log /var/log/nginx/error.log; 

/etc/nginx/nginx.confデフォルトで以下の行を追加します。 (access_logおよびerror_log行はすでにtに存在しています彼は既定の設定、私は文脈のためだけにこれらをここに入れました)。

私はその後でnginxのを再起動します。

systemctl restart nginx 

私は今、私のログが変更することを期待し、特に使用xxxのリテラル値を表示する。.. XXX [$ time_local] xxxの..しかし、私の変更は違いはありません。私は組み合わせLOG_FORMATメインにLOG_FORMATを変更した場合は

は、サーバーが再起動しません。

答えて

2

..

access_log /var/log/nginx/access.log; 

が..

access_log /var/log/nginx/access.log main; 

はそれを修正するために変更します。で定義されるよう メインはLOG_FORMATの名前である..

log_format main '$remote_addr - $remote_user xxx[$time_local]xxx ' 
       '"$request" $status $body_bytes_sent ' 
       '"$http_referer" "$http_user_agent"'; 

関連する問題