Nginx重复的log_format名称timed_combined错误。

3
我遇到了这个错误:
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';
1个回答

9

"timed_combined"日志格式在源代码中预定义; 您需要使用您的名称来替换它,例如:

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

然后您需要重新定义access_log:

access_log /path/to/access.log my_log


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接