简体   繁体   English

如何制作日志旋转导轨3.2.8版本

[英]how make log rotation rails 3.2.8 version

How can I make log rotation on my production env for rails version 3.2.8? 如何在3.2.8版的rails的生产环境中进行日志旋转?

I have taking a look to Ruby on Rails production log rotation , but is for old rails version. 我看了一下Ruby on Rails生产日志的轮换 ,但是它适用于旧的Rails版本。

I use nginx + unicorn 我用Nginx +独角兽

Where can I find more info about this? 在哪里可以找到更多有关此的信息?

Thank you very much! 非常感谢你!

This shell script worked for me. 这个shell脚本为我工作。 I set up cron to execute this script every night, just before midnight. 我将cron设置为每天晚上午夜之前执行此脚本。 You'll need to adjust the directories to your own application. 您需要根据您自己的应用程序调整目录。 Note that the directory references are relative to my application's root directory. 请注意,目录引用是相对于我的应用程序的根目录而言的。 The "kill" command tells the master unicorn process to reload, which automatically creates a new production.log and unicorn.log file. “ kill”命令告诉主unicorn进程重新加载,该过程会自动创建一个新的production.log和unicorn.log文件。

#!/bin/bash
# Rotates unicorn.log and production.log files located
# in the <application_root>/log folder.
# Deletes compressed logs older than 60 days.
NOW=`date +%Y%m%d_%H%M%S`
cd /home/deployer/apps/stations/current
mv log/production.log log/production_$NOW.log
mv log/unicorn.log log/unicorn_$NOW.log
kill -s USR1 `cat tmp/pids/unicorn.pid`
sleep 1
gzip log/production_$NOW.log
gzip log/unicorn_$NOW.log
find log/ -type f -mtime +60 -name "*.gz" -delete

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM