【问题标题】:Nginx duplicate log_format name timed_combined errorNginx 重复 log_format 名称 timed_combined 错误
【发布时间】:2018-01-14 06:13:57
【问题描述】:

我收到此错误:

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';

【问题讨论】:

    标签: web-services nginx server


    【解决方案1】:

    “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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-01-28
      • 2021-03-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多