这是一个很容易被忽视的问题,尤其是对于新入门的Rails程序员。默认设置时,Rail程序在运行的时候,提供了很详细的Log,Log文件快速增长会占用大量的服务器空间,文件一般保存在rails的app/log/目录下。
Rails可以通过选择不同的log lever来控制log文件的输出,可以使用的log lever有:debug, :info, :warn, :error, :fatal.
:debug level提供最详细的log, 可以将每一条sql都记录下来。
:info level是production环境下的默认设置,不会写出sql的执行情况,但也会很详细,如果是ActiveMailer,它会记录下每封信的内容,Log文件内容就是快速增长。为了避免Log把空间塞满的情况发生,要注意定期清除Log,另外是选择:warn
level等log level, 只记录重要的信息.
设置方法:
在/config/environment.rb文件中可以设置以下选项
config.log_level = :debug #实际上只是把这行的注释取消就可以了
如果只希望在production环境下,输入少量的log,
则只需要在config/environments/production.rb中增加一项(我就是这样设置的)
config.log_level = :warn
文章转自:http://www.tagriver.com/viewpost.php?postid=41278
原作者:Cai
分享到:
相关推荐
帮组你深入理解rails的内部原理, 实作rails的各个部件
8 Setting up a Todo application in Rails 8 Analyzing folder structure of a Rails application 10 Creating views 12 Styling views using CSS 14 Redesigning the Todo application 16 Challenges in styling ...
Ruby.on.Rails.Enterprise.Application.Development
Build your own ruby on rails web application
jquery-fileupload-rails, 用于 Rails的jQuery文件上传集成 Rails 文件上传jQuery-File-Plugin 是一个文件上传插件,由的Tschan 。 jQuery文件上传功能多文件选择。drag&拖放支持。进度栏和jQuery预览图像。 支持...
Rails 4 Application Development.pdf
Ruby on Rails Enterprise Application Development.pdf Ruby Rails企业应用程序开发
NULL 博文链接:https://zyn-zyn.iteye.com/blog/1163143
可实现多文件的同时上传,控制文件的格式,数量,同时兼容IE6,7,firefox,易于扩展
Paperclip 是 Rails 框架的一个插件,用于扩展 ActiveRecord 以支持简单的文件附件的功能。 标签:Paperclip
Docker and Kubernetes are increasing in popularity every day, but what if you want to leverage their benefits for your Rails application? This is the book you need. Deploying Rails with Docker, ...
NULL 博文链接:https://mylir.iteye.com/blog/800734
NULL 博文链接:https://dendrobium.iteye.com/blog/305938
Your Ruby on Rails application is sick. Deadlines are looming, but every time you make the slightest change to the code, something else breaks. Nobody remembers what that tricky piece of code was ...
Rails 经典开发参考书, Ruby on rails 系近年来在西方日渐盛行的一套网页开发工具,其高度集成化时开发时间大大缩短.
rails_layout, 为各种前端框架生成 Rails 应用程序布局文件 RailsLayout gem使用这里 gem 可以设置你选择的前端框架的布局文件:Zurb基础 5.3Bootstrap 4.0Bootstrap 3.3它还将为 Bootstrap 或者基础设置设计视图。...
Rails for Zombies. This is a tutorial of ruby on rails application.
css和图片 博文链接:https://hideto.iteye.com/blog/197517
It's famously simple to build a basic Rails application. Once you've started down the track, however, you discover that Rails is a powerful, deep, and rich full-stack platform capable of tackling ...