Can I simply delete the log files?

Hi there

I wanted to upload a Rails app and saw that the log files are 16mb big!
Can I simply delete them? Will Rails create automatically new ones when
needed? Or do I have to empty them so they aren’t that big anymore…?

Thanks for info.
Josh

Joshua M. wrote:

Hi there

I wanted to upload a Rails app and saw that the log files are 16mb big!
Can I simply delete them? Will Rails create automatically new ones when
needed? Or do I have to empty them so they aren’t that big anymore…?

Thanks for info.
Josh

You can include this in your environment.rb file:
RAILS_DEFAULT_LOGGER =
Logger.new("#{RAILS_ROOT}/log/#{RAILS_ENV}.log", 20, 10.megabyte)

Put it beneath the line: require File.join(File.dirname(FILE),
‘boot’)

This line will make rails automatically rotate your logs. In this
instance, it will rotate the log whenever it hits 10 megabytes, and it
will keep the most recent 20 files.

Or, if you really don’t need them, you can use:

rake clear_logs

you can delete them.

“Jon C.” wrote:

instance, it will rotate the log whenever it hits 10 megabytes, and it
will keep the most recent 20 files.

I just want to add that the above code works very well in development.
However, in production it causes the rails app to die with error code
500.

Further investigation show when rotate is triggered, rails looses
complete
access to the production.log file. I just found out how sensitive rails
is not
able to write to its log. In my case Apache logged a dispatcher.fcgi
error
due to sending incomplete header information (35 bytes).

So why is rails so sensitive about the log file? Can or should this be
changed
to fail write quietly or less violent?

What other ways to rotate the log file, safely?

Thanks for your insight,

Long

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs