nginx配置access_log问题

新手上路,请多包涵

我想给nginx开启访问日志。百度了一下,主要是在nginx.conf中配置

clipboard.png

这一段

#    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
#                      '$status $body_bytes_sent "$http_referer" '
#                      '"$http_user_agent" "$http_x_forwarded_for"';
#
#    access_log  logs/access.log  main;

默认都是加#注释掉的,我想开启,也就是这段都取消#注释了。
然后重启nginx却重启不了,提示
Job for nginx.service failed because the control process exited with error code. See "systemctl status nginx.service" and "journalctl -xe" for details.

把#加回去又没事了,什么原因啊,
包括开头的错误日志

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

也是把#去掉想生效,结果nginx就启动不了。
`

阅读 4.8k
1 个回答

1.请使用 nginx -t 检查配置文件获取 查看具体得错误信息

日志这样处理

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

   access_log  logs/access.log  main;
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题