简体   繁体   English

Rails记录器旋转=>其他进程可以写入同一日志文件吗?

[英]Rails logger rotation => Can other processes write to the same log file?

In my config/environments/production.rb, I have the following: 在我的config / environments / production.rb中,我具有以下内容:

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. 假设我从未在代码中的任何地方写入此log / production.log。 However, I have another process (say a Java process) that writes to this same log file. 但是,我有另一个进程(例如Java进程)写入此相同的日志文件。 Assuming Rails is up and running, will Rails automatically do the autorotation, even if Rails never writes to this log file? 假设Rails已启动并正在运行,即使Rails从未写入此日志文件,Rails也会自动进行自动旋转吗?

No, Ruby does rotation only on own write: 不,Ruby仅在自己的写操作中进行轮换:

https://github.com/ruby/ruby/blob/ruby_2_3/lib/logger.rb#L648 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. 另外,从不同的进程写入同一文件可能不是一个好主意。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM