nginx日志过滤(Nginx log filtering)

1、一个网站,会包含很多元素,尤其是有大量的图片、js、css等静态元素。这样的请求其实可以不用记录日志。

location ~* ^.+\.(gif|jpg|png|css|js)$ 
{
    access_log off;
}

或
location ~* ^.+\.(gif|jpg|png|css|js)$                                      
{
    access_log /dev/null;
}

2、nginx方向代理了nacos之后,打大量nacos相关日志,过滤有关nacos日志

   location ~*  .*nacos.* {
       access_log off;
   }
————————

1. A website will contain many elements, especially a large number of static elements such as pictures, JS and CSS. In fact, such requests do not need to be logged.

location ~* ^.+\.(gif|jpg|png|css|js)$ 
{
    access_log off;
}

或
location ~* ^.+\.(gif|jpg|png|css|js)$                                      
{
    access_log /dev/null;
}

2. After nginx proxies Nacos, it creates a large number of Nacos related logs and filters Nacos related logs

   location ~*  .*nacos.* {
       access_log off;
   }