I\'ve had great experiences with Sunspot Solr search for Ruby on Rails, however, its log files are growing incredibly large and I can\'t seem to find a way to either rot
I've monkey patched the appropriate file in sunspot_solr to resolve this exact issue.
This code is not robust enough to survive rearchitecting/refactoring done directly in the sunspot_solr gem, so I recommend locking your sunspot_solr gem version to 1.3.0 for this to succeed.
You can drop the following into your project. We use it in a Rails project and have placed it at lib/sunspot/solr/server.rb:
module Sunspot
module Solr
class Server #:nodoc:
def logging_config_path
puts "# ==> Using monkey-patched Sunspot::Solr::Server#logging_config_path method"
return @logging_config_path if defined?(@logging_config_path)
@logging_config_path =
if log_file
logging_config = Tempfile.new('logging.properties')
logging_config.puts("handlers = java.util.logging.FileHandler")
logging_config.puts("java.util.logging.FileHandler.level = #{log_level.to_s.upcase}")
logging_config.puts("java.util.logging.FileHandler.pattern = #{log_file}")
logging_config.puts("java.util.logging.FileHandler.formatter = java.util.logging.SimpleFormatter")
# >>> ADDED THE FOLLOWING TWO LINES FOR JAVA-BASED LOG ROTATION <<<
logging_config.puts("java.util.logging.FileHandler.count = 7")
logging_config.puts("java.util.logging.FileHandler.limit = 104857600") # 100 megs
logging_config.flush
logging_config.close
logging_config.path
end
end
end # class Server
end # module Solr
end # module Sunspot