nginx 直接在配置文章中设置日志分割
2015-08-10 20:06
706 查看
直接在nginx配置文件中,配置日志循环,而不需使用logrotate或配置cron任务。需要使用到$time_iso8601 内嵌变量来获取时间。$time_iso8601格式如下:2015-08-07T18:12:02+02:00。然后使用正则表达式来获取所需时间的数据。
按天分割日志
使用下面的代码块if ($time_iso8601 ~ "^(\d{4})-(\d{2})-(\d{2})") { set $year $1; set $month $2; set $day $3; } access_log /data/logs/nginx/www.ttlsa.com-$year-$month-$day-access.log;
按时、分、秒分割
if ($time_iso8601 ~ "^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})") { set $year $1; set $month $2; set $day $3; set $hour $4; set $minutes $5; set $seconds $6; }
相关文章推荐
- nginx虚拟目录配置(php-fpm+fastcgi)
- nginx配置文件详解
- LNMP的Nginx启动脚本和配置文件
- linux centos6.5安装tengine(nginx)
- LNMP—Nginx的编译安装
- nginx + unicorn 配置
- Nginx配置文件详细说明
- windows配置nginx实现负载均衡集群
- linux 下搭建Nginx+php报错open_basedir restriction in effect. File(/var/www/html/index.php) is not within
- 如何收集 NGINX 指标(第二篇)
- 一台nginx服务器多域名配置 (转)
- LNMP编译安装(centos7+nginx1.9+mysql5.6+php5.5)
- lnmp环境安装(2)-nginx安装
- nginx安装
- N年前Nginx 负载均衡在金山逍遥网中的应用
- Nginx 笔记与总结(10)Nginx 与 PHP 整合
- 01_Nginx安装,nginx下部署项目,nginx.conf配置文件修改,相关文件配置
- 01_Nginx安装,nginx下部署项目,nginx.conf配置文件修改,相关文件配置
- nginx学习记录
- nginx - 性能优化,突破十万并发