nginx开启和关闭访问日志功能配置
nginx开启和关闭日志功能的配置
1.开启nginx访问日志
server{ //其他配置省略 log_format main '$remote_addr - $remote_user [$time_local] ' '"$request" $status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; //日志格式,注意log_format在配置文件中只能出现一次 access_log /www/logs/xx.com.log ; //日志记录所在 }
2.关闭nginx访问日志
server{ //其他配置省略 log_format main '$remote_addr - $remote_user [$time_local] ' '"$request" $status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; //日志格式,注意log_format在配置文件中只能出现一次 access_log off ; //日志记录所在 }
3.开启nginx访问日志但不记录css和图片
server{ //其他配置省略 log_format main '$remote_addr - $remote_user [$time_local] ' '"$request" $status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; //日志格式,注意log_format在配置文件中只能出现一次 location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ { expires 30d; access_log off; } location ~ .*\.(js|css)?$ { expires 12h; access_log off; } access_log /www/logs/xx.com.log ; //日志记录所在 }
您可能感兴趣的文章:
nginx php-fpm 输出php错误日志
Nginx 安装配置
nginx+php-fpm页面显示空白的解决方法
如何用aws运行python
如何开启Nginx的gzip压缩功能
Docker 安装 Nginx
如何在CentOS和RHEL和Fedora上安装NGINX Web服务器
php在服务器如何看请求日志
隐藏PHP版本的方法 PHP基本安全设置
php-fpm 启动参数配置详解