
nginx日志文件配置
ulimit -n 655350 修改linux内核对一个进程打开文件数量的限制,修改为655350 临时修改 如何永久有效? 1./etc/rc.local ulimit -n 655350 2.修改/etc/security/limits.conf vim /etc/security/limits.conf * soft nofile 1000000 * hard nofile 1000000
发布日期:2021-07-27 04:45:19
浏览次数:10
分类:技术文章
本文共 2382 字,大约阅读时间需要 7 分钟。
文章目录
#nofile - max number of open file descriptors
错误日志
日志:记录程序在运行过程中发生的事情
时间 + 地点 + 人物 +事件 日志的作用:排错、解决故障、调试优化日志的级别–》重要程度
none --》没有 --》级别低 debug --》调试信息 info–》正常的信息 information notice --》通知 warning --》警告 error --》错误 --》导致程序不能运行 critical --》严重 emergency --》急求 --》级别高 默认为crit级别语法格式:
Syntax:error_log file [level]; 示例: error_log logs/www_error.log error;
日志访问日志
官方链接:http://nginx.org/en/docs/http/ngx_http_log_module.html#access_log#定义日志出输格式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; 参数说明:$remote_addr:客户端访问的源IP信息$remote_user:客户端用户认证信息[$time_local]:显示访问时间$request:请求行信息$status:状态码信息$body_bytes_sent:服务端响应给客户端的数据大小信息$http_referer:记录链接到网站的域名信息$http_user_agent:用户访问网站客户端软件标识信息$http_x_forwarded_for:反向代理
示例:
#编写配置文件,添加访问日志[root@web01 conf]# cat nginx.confworker_processes 1;error_log logs/www_error.log error;events { worker_connections 1024;}http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; include extra/www.conf; include extra/bbs.conf; include extra/blog.conf; 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/www_access.log main;}#重启服务之后,测试访问[root@web01 conf]# ../sbin/nginx -s reload[root@web01 conf]# curl bbs.etiantian.org10.0.0.7 bbs.etiantian.org#日志输出10.0.0.7 - - [25/Feb/2019:11:58:30 +0800] "GET / HTTP/1.1" 200 27 "-" "curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.21 Basic ECC zlib/1.2.3 libidn/1.18 libssh2/1.4.2" "-"
因日志文件数据过大,需进行日志分割
使用sehll脚本进行日志分割[root@web01 scripts]# vim cut_log.sh#!/bin/bashdata_info=$(date +%F-%H:%M)mv /application/nginx/logs/www_access.log /application/nginx/logs/access.log.$data_info /application/nginx/sbin/nginx -s reload #设置定时任务# cut nginx log cron* */6 * * * /bin/sh /server/scripts/cut_log.sh &>/dev/null
转载地址:https://blog.csdn.net/qq_45206551/article/details/105414731 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!
发表评论
最新留言
第一次来,支持一个
[***.219.124.196]2025年01月26日 07时20分29秒
关于作者

喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!
推荐文章
Shell编程中的“局部变量”和“导出变量”
2019-06-30
Struts2值栈学习
2019-06-30
JVM学习总结(六)内存分配与回收策略
2019-06-30
js生成随机颜色
2019-06-30
三年半 Java 后端鹅厂面试经历
2019-06-30
android:onClick详解
2019-06-30
InnoDB体系架构(基础篇)
2019-06-30
LVS原理详解及部署之一:ARP原理准备
2019-06-30
JAVA字符串格式化-String.format()的使用
2019-06-30
Shell 编程
2019-06-30
如何终止java线程
2019-06-30
探究权限系统集中安全性管理
2019-06-30
Android中dip、dp、sp、pt和px的区别
2019-06-30
模拟器Emulator(便携版)的安装使用
2019-06-30
java 1.8
2019-06-30
验证码
2019-06-30
wap UI
2019-06-30
我的友情链接
2019-06-30
Mysql主从同步
2019-06-30
读 Slim 框架代码(2)
2019-06-30