nginx日志问题解决方法记录
nginx版本信息如下
#nginx -V
nginx version: nginx/1.2.0 最新稳定版本
built by gcc 4.4.6 20110731 (Red Hat 4.4.6-3) (GCC)
TLS SNI support enabled
configure arguments: --prefix=/usr --sbin-path=/usr/sbin --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-ath=/var/log/nginx/nginx.pid --lock-path=/var/lock/nginx.lock --user=www --group=www --with-http_ssl_module --with-ttp_flv_module --with-http_mp4_module --with-http_gzip_static_module --with-http_stub_status_module --with-google_perftools_module --http-proxy-temp-path=/var/tmp/nginx/proxy --http-fastcgi-temp-path=/var/tmp/nginx/fcgi --http-client-body-temp-path=/var/tmp/nginx/client --http-uwsgi-temp-path=/var/tmp/nginx/uwsgi --http-scgi-temp-path=/var/tmp/nginx/scgi
|
nginx的配置如下
- user www;
- worker_processes 2;
- google_perftools_profiles /var/tmp/nginx/tcmalloc/tcmalloc;
- events {
- use epoll;
- worker_connections 51000;
- }
- http
- {
- include mime.types;
- default_type application/octet-stream;
- keepalive_timeout 65;
- sendfile on;
- tcp_nopush on;
- tcp_nodelay on;
- client_header_timeout 10;
- client_body_timeout 10;
- send_timeout 10;
- gzip on;
- gzip_min_length 1k;
- gzip_buffers 4 16k;
- gzip_http_version 1.1;
- gzip_comp_level 2;
- gzip_types text/plain application/x-javascript text/css applocation/xml;
- server {
- listen 80;
- server_name localhost;
- location / {
- root html;
- index index.html index.htm;
- }
- error_page 500 502 503 504 /50x.html;
- location = /50x.html {
- root html;
- }
- location ~ \.php$ {
- root html;
- fastcgi_pass 127.0.0.1:9000;
- fastcgi_index index.php;
- fastcgi_param SCRIPT_FILENAME /usr/html$fastcgi_script_name;
- include fastcgi_params;
- }
- log_format welog '$remote_addr - $remote_user [$time_local] "$request" '
- '$status $body_bytes_sent "$http_referer" '
- '"$http_user_agent" "$http_x_forwarded_for"';
- access_log /var/log/nginx/access.log weblog;
- }
- }
- 启动nginx的时候,出现警告信息
- #service nginx restart
- nginx: [warn] the "log_format" directive may be used only on "http" level in /etc/nginx/nginx.conf:97
- nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
- nginx: configuration file /etc/nginx/nginx.conf test is successful
- Stopping nginx: [ OK ]
- Starting nginx: nginx: [warn] the "log_format" directive may be used only on "http" level in /etc/nginx/nginx.conf:97
- [ OK ]
- 这里的警告意思是日志需要放在http内,所以做如下更改即可
修改后的nginx.conf文件如下
- user www;
- worker_processes 2;
- google_perftools_profiles /var/tmp/nginx/tcmalloc/tcmalloc;
- events {
- use epoll;
- worker_connections 51000;
- }
- http
- {
- include mime.types;
- default_type application/octet-stream;
- keepalive_timeout 65;
- sendfile on;
- tcp_nopush on;
- tcp_nodelay on;
- client_header_timeout 10;
- client_body_timeout 10;
- send_timeout 10;
- gzip on;
- gzip_min_length 1k;
- gzip_buffers 4 16k;
- gzip_http_version 1.1;
- gzip_comp_level 2;
- gzip_types text/plain application/x-javascript text/css applocation/xml;
- server {
- listen 80;
- server_name localhost;
- location / {
- root html;
- index index.html index.htm;
- }
- error_page 500 502 503 504 /50x.html;
- location = /50x.html {
- root html;
- }
- location ~ \.php$ {
- root html;
- fastcgi_pass 127.0.0.1:9000;
- fastcgi_index index.php;
- fastcgi_param SCRIPT_FILENAME /usr/html$fastcgi_script_name;
- include fastcgi_params;
- }
- } 注意,下面的日志是放在server之外的,即出现警告是放的位置不对
- log_format welog '$remote_addr - $remote_user [$time_local] "$request" '
- '$status $body_bytes_sent "$http_referer" '
- '"$http_user_agent" "$http_x_forwarded_for"';
- access_log /var/log/nginx/access.log weblog;
- }
重启nginx服务,则OK了,
- service nginx restart
- nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
- nginx: configuration file /etc/nginx/nginx.conf test is successful
- Stopping nginx: [ OK ]
- Starting nginx: [ OK ]
如果我需要在server里面定义日志,该怎么实现呢,如下
- user www;
- worker_processes 2;
- google_perftools_profiles /var/tmp/nginx/tcmalloc/tcmalloc;
- events {
- use epoll;
- worker_connections 51000;
- }
- http
- {
- include mime.types;
- default_type application/octet-stream;
- keepalive_timeout 65;
- sendfile on;
- tcp_nopush on;
- tcp_nodelay on;
- client_header_timeout 10;
- client_body_timeout 10;
- send_timeout 10;
- gzip on;
- gzip_min_length 1k;
- gzip_buffers 4 16k;
- gzip_http_version 1.1;
- gzip_comp_level 2;
- gzip_types text/plain application/x-javascript text/css applocation/xml;
- server {
- listen 80;
- server_name localhost;
- location / {
- root html;
- index index.html index.htm;
- }
- error_page 500 502 503 504 /50x.html;
- location = /50x.html {
- root html;
- }
- location ~ \.php$ {
- root html;
- fastcgi_pass 127.0.0.1:9000;
- fastcgi_index index.php;
- fastcgi_param SCRIPT_FILENAME /usr/html$fastcgi_script_name;
- include fastcgi_params;
- }
- access_log /var/log/nginx/access2.log; 此处定义的日志格式,不需要在后面加日志格式
- } 注意,下面的日志是放在server之外的,即出现警告是放的位置不对
- log_format welog '$remote_addr - $remote_user [$time_local] "$request" '
- '$status $body_bytes_sent "$http_referer" '
- '"$http_user_agent" "$http_x_forwarded_for"';
- access_log /var/log/nginx/access.log weblog;
- }
转载于:https://blog.51cto.com/itnihao/851716
nginx日志问题解决方法记录相关推荐
- cannot create file怎么解决_内核问题解决方法记录
内核问题解决方法记录 ♪ 张释文 在内核开发这块,基本工作都是:打补丁,调补丁,调bug.最耗神的就是调bug,调bug的过程最花时间的一步是定位问题,基本上只要定位到问题,解决起来就容易些了(目前我 ...
- VS2008运行过程中出现regsvr32问题解决方法记录
VS2008运行过程中出现regsvr32问题解决方法 vs2008运行工程文件过程中提示regsvr32出现问题,此时我的项目中有3个工程,两个是依赖,第三个是我建立的运行工程,出现这个问题之后,我 ...
- centos yum安装nginx 提示 No package nginx available问题解决方法
问题原因: nginx位于第三方的yum源里面,而不在centos官方yum源里面 解决方法: 安装epel(Extra Packages for Enterprise Linux) a.去epel网 ...
- android应用开发中收集的异常日志解决方法记录
这里主要是列出开发中收集的一些错误日志,以及解决方案,仅供参考,也有待解决的问题 1, ListView 中出现java.lang.IndexOutOfBoundsException: Invalid ...
- Idea中Maven控制的多模块项目运行不到最新的代码,写的代码不生效问题解决方法记录。
文章目录 写在前边 我的情况 解决办法 原因分析 写在前边 这个方法不一定适合所有情况,兄弟遇到这种情况首先需要保持冷静.可以先参考我们的情况是否一致,再决定是否看下去. 我的情况 idea版本:20 ...
- Ubuntu上Github下载慢的问题解决方法记录
1.程序员们经常使用git clone +网址下载github上的代码,但是只有几k的速度,然后经常中途下载失败.现记录一下自己的解决办法.git clone特别慢是因为github.global.s ...
- Ubuntu18上Github下载慢的问题解决方法记录
1.程序员们经常使用git clone +网址下载github上的代码,但是只有几k的速度,然后经常中途下载失败.现记录一下自己的解决办法.git clone特别慢是因为github.global.s ...
- 关于keil常见问题解决方法记录error: #268: declaration may not appear after executable statement in block
error: #268: declaration may not appear after executable statement in block 因为keil 默认编译标准是C89,解决方法:
- 关于pycharm+opencv没有代码提示的问题解决方法记录
代码可以看出实际我们引入的应该是cv2.cv2下面. 所以我们代码只需要import cv2.cv2 as cv 即可. 记着要重新启动下pycharm哦. 可以参考: https://blog.cs ...
最新文章
- 精华阅读第 10 期 |解开阿尔法狗(AlphaGo)人工智能的画皮
- 常见文件、目录、路径操作函数
- 【2012百度之星/资格赛】C: 易手机的套餐
- caffe训练输入数据格式介绍(LMDB/imagelist)
- 128位java_求一个java算法,用128位密钥的AES加密128位明文,得出的密文还是128位...很着急,非常感谢各位大神,求救!...
- 【.NET Core 3.0】 46 ║ 授权认证:自定义返回格式
- Git操作常用的命令都在这里了
- PCL学习(三) SAC-IA 估记object pose
- 大数据_Flink_Java版_状态管理(2)_算子状态---Flink工作笔记0061
- 第45届国际大学生程序设计竞赛(ICPC)沈阳站太原理工大学收获1枚铜牌
- 100 个 pandas 案例,强烈建议保存
- 牛逼!一款基于SpringBoot的微信点餐系统
- 怎么制作html静态页面,如何做静态网页
- 南京邮电大学离散数学实验一(求主析取和主合取范式)
- 固定资产管理系统项目总结
- STM32开源代码——TM1637四位数码管
- PS4 自建HEN服务器 | 使用IDM 克隆整个网站
- 企业上云成趋势 看超融合如何开箱即用、一步上云
- PCL5打印机命令语言功能参考
- 08-微服务版单点登陆系统(SSO)实践
热门文章
- SAP WM 有无保存WM Level历史库存的Table?
- torch_{geometric/scatter}中一些函数的用法(softmax,scatter)
- 人为什么要睡觉?科学家给出进一步答案
- 认知科学顶刊:挑战过去50年神经科学观点,人类智力的优势或来自于记忆储存方式...
- Python 什么时候会被取代?
- Gartner 2019 年 BI 炒作周期五大趋势:增强分析、数字文化、关系分析、决策智能、实施和扩展...
- 最先进的AI还不如动物聪明?首届AI-动物奥运会英国开赛!
- 科学:揭示自由意志的生物学本质
- 脑机交互研究及标准化实践
- “强化学习之父”萨顿:预测学习马上要火,AI将帮我们理解人类意识