Closed dvdplm closed 10 years ago
I put a patch into SemanticLogger to allow re-opening of the File Appender.
Add the following to the Gemfile before rails_semantic_logger:
gem 'semantic_logger', :git => 'git://github.com/ClarityServices/semantic_logger.git'
Then update the above code as follows:
after_fork do |server, worker|
if defined?(ActiveRecord::Base)
ActiveRecord::Base.establish_connection
# Re-open the File Appender
SemanticLogger.reopen
Rails.logger.info('Connected to ActiveRecord')
end
if defined?(Resque)
Resque.redis = ENV['REDIS_RESQUE_URL']
Rails.logger.info("Resque connected to Redis at #{ENV['REDIS_RESQUE_URL']}")
end
end
This feature is also useful if anyone wants to delete the log file rather than use a coney truncate approach to log file rotation.
Let me know if this works and I will publish the gem for it
We have an issue where no logging happens in our rails app after our before_fork handler executes on a deploy.
What is the right way to re-initialize SemanticLogger after the fork? (I'm guessing that is what happens).
We currently have code like this in the unicorn.conf:
We do not see those two log messages (and none of the others). Pointers?