I'm making use of log rotation within a Rails app, which seems to function. However, the new log files are owned by the root
user rather than the apps
user. The application is running via Passenger which is using the apps
user too.
Is it possible to have the new logs created by / owned by the apps
user instead of root
?
The config I'm using in production.rb
is below:
# Use default logging formatter so that PID and timestamp are not suppressed.
config.log_formatter = ::Logger::Formatter.new
config.logger = Logger.new(config.paths["log"].first, 3, 10.megabytes)
# Use a different logger for distributed setups.
# require 'syslog/logger'
# config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name')
if ENV["RAILS_LOG_TO_STDOUT"].present?
logger = ActiveSupport::Logger.new(STDOUT)
logger.formatter = config.log_formatter
config.logger = ActiveSupport::TaggedLogging.new(logger)
end