分开存储Rails web日志文件和sql日志
原文
首先,在rails_project/log/目录下新建sql文件夹,sql文件夹用来保存sql日志
接着,修改rails_project/config/environment.rb代码,需注意代码顺序。
#web访问日志
RAILS_DEFAULT_LOGGER = Logger.new("#{RAILS_ROOT}/log/#{RAILS_ENV}#{Date.today.to_s}.log", "daily")
#rails的初始化
Rails::Initializer.run do |config|
#...
end
#sql日志
ActiveRecord::Base.logger = Logger.new("#{RAILS_ROOT}/log/sql/#{RAILS_ENV}#{Date.today.to_s}.log", "daily")
No comments :
Post a Comment