0

In my config/environments/production.rb, I have the following:

config.logger = Logger.new("log/production.log", 10, 1000.megabytes)
config.log_formatter = ::Logger::Formatter.new

Let's suppose I never ever write to this log/production.log anywhere in my code. However, I have another process (say a Java process) that writes to this same log file. Assuming Rails is up and running, will Rails automatically do the autorotation, even if Rails never writes to this log file?

Henley
  • 21,258
  • 32
  • 119
  • 207

1 Answers1

1

No, Ruby does rotation only on own write:

https://github.com/ruby/ruby/blob/ruby_2_3/lib/logger.rb#L648

Also, it's probably not a good idea to write to the same file from different processes.

Mladen Jablanović
  • 43,461
  • 10
  • 90
  • 113
  • I said probably, so I haven't tried that myself. Quick googling suggests it's not trivial: http://stackoverflow.com/questions/7842511/safe-to-have-multiple-processes-writing-to-the-same-file-at-the-same-time-cent http://blogs.perl.org/users/vyacheslav_matjukhin/2011/05/suprisingly-hard-task-of-writing-logs.html – Mladen Jablanović Jul 20 '16 at 19:48