2017-08-07 48 views
1

我收到此錯誤:Nginx的重複log_format名timed_combined錯誤

Restarting nginx: nginx: [emerg] duplicate "log_format" name "timed_combined" in /etc/nginx/sites-enabled/default:8 
nginx: configuration file /etc/nginx/nginx.conf test failed 

每當我特林啓動或重新啓動我的nginx服務器。這以前不會發生。下面是代碼的前幾行,我/etc/nginx/sites-enabled/default

# You may add here your 
# server { 
#  ... 
# } 
# statements for each of your virtual hosts 
log_format timed_combined '$remote_addr - $remote_user [$time_local] ' 
     '"$request" $status $body_bytes_sent ' 
     '"$http_referer" "$http_user_agent" $request_time'; 

回答

0

的「timed_combined」 log_format在源預定義的;你需要用你的名字,是這樣的:

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

之後,你需要重新定義訪問日誌:

access_log /path/to/access.log my_log