Skip to content

Instantly share code, notes, and snippets.

@rubyonrailsworks
Created October 24, 2012 06:20
Show Gist options
  • Save rubyonrailsworks/3944341 to your computer and use it in GitHub Desktop.
Save rubyonrailsworks/3944341 to your computer and use it in GitHub Desktop.
automation
# config/initializers/clear_logs.rb
if Rails.env.development?
MAX_LOG_SIZE = 10.megabytes
logs = [ File.join(Rails.root, 'log', 'development.log'), File.join(Rails.root, 'log', 'test.log') ]
logs.each do |log|
if File.size?(log).to_i > MAX_LOG_SIZE
$stdout.puts "Removing Log: #{log}"
`rm #{log}`
end
end
end
logger级别
debug, info, warn, error, and fatal.
默认情况下:开发和测试环境下日志级别为所有(>=debug),生产环境级别为>=info
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment