English 中文(简体)
原始数值。 认为被忽视
原标题:log_format in nginx.conf being ignored
  • 时间:2017-01-08 01:03:18
  •  标签:
  • nginx

Total NGINX beginner here.

我的标志目前喜欢:

92.21.236.47 - [08/Jan/2017:00:48:10 +0000] “GET / HTTP/1.1” 200 148“-”“Mozilla/5.0(Windows NT 10.0;WOW64;rv:50.0) Gecko/20100101/560.0”

When I add the following line in the default /etc/nginx/nginx.conf

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;

(在缺省会已经存在接触线和错误线,因此我仅作此解释。)

接着,我重新召集国家地理信息小组会议:

systemctl restart nginx

现在,我预计我的原木会发生变化,特别是显示所用的xxx字面值。

If I change log_format main to log_format combined then the server won t restart.

最佳回答

变化。

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

页: 1

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

固定。

<>main 是按......定义的标识名称。

log_format main  $remote_addr - $remote_user xxx[$time_local]xxx  
                 "$request" $status $body_bytes_sent  
                 "$http_referer" "$http_user_agent" ;
问题回答

很晚才作出答复,但对于仍在这一 pro折中的人可能是有益的。

书写<条码>log_format Directiveexternalrserver{>

整个法典就是这样。

log_format main  $remote_addr - $remote_user xxx[$time_local]xxx  
                 "$request" $status $body_bytes_sent  
                 "$http_referer" "$http_user_agent" ;
server {
      listen 80;
      access_log /var/log/nginx/<your_domain>_access.log main; 
}

此处主要指原产地在撰写标识时应当包括哪些领域。

For more detail information, Please look in the official documentation Sampling Requests with NGINX Conditional Logging

以上2项答复尝试了,但确实提供了帮助。 (一) 认识到

above the log_format line in my nginx.conf, server brace was not closed. and it gave me the same error.

In my case, finnally find out that my nginx was using a different config file:

changes was made to /usr/local/nginx/conf/nginx.conf but actually /usr/local/nginx/nginx.conf was in use.





相关问题
nginx behaved differently for different version

I have used docker image nginx:1.18.0-alpine previously and below is the conf. It works as expected app.localhost --> points to the block wit server_name app.* localhost --> points to the other ...

What s limiting my PHP resources?

I m having a problem getting more memory out of PHP. This is the error message: Fatal error: Allowed memory size of 20971520 bytes exhausted (tried to allocate 82 bytes) in ... Yet: I ve set ...

what user I should run my nginx or php-fpm processes

Ok. Im little bit confused about those permissions in linux so please people help me out. The trouble is that I dont want to run server as root, so I created another user with sudo privileges so he ...

Nginx 301 redirect inc. set cookie

what I m looking for is the ability for nginx to detect that a url has the query string variable cid. for example www.adomain.com/froggy?cid=12&as=false (query string can be solo or mixed with ...

Nginx raises 404 when using format => js

I upload images to my App using Ajax and an Iframe. In Development everything works like a charm. But in production Nginx suddenly raises a 404 error. When I look into the log, the request never hits ...

nginx errors readv() and recv() failed

I use nginx along with fastcgi. I see a lot of the following errors in the error logs readv() failed (104: Connection reset by peer) while reading upstream and recv() failed (104: Connection ...

SSL slowness in EC2

We ve deployed our rails app to EC2. In our setup, we have two proxies on small instances behind round-robin DNS. These run nginx load balancers for a dynamically growing and shrinking farm of web ...

热门标签