sunspot/sunspot — Issue #186: solr server: rotating log files
Author: mv288
Created: 2012-02-23 01:35:18+00:00
State: open

The java.util log settings file generated from sunspot_solr / lib / sunspot / solr / server.rb does not rolling log support.
Adding these 2 lines gives the rolling log support.

logging_config.puts("java.util.logging.FileHandler.limit=102400")
logging_config.puts("java.util.logging.FileHandler.count=2")

Without above lines a single log file, solr_production.log gets generated and it grows infinitely.

We monkey patched the Sunspot::Rails::Server. logging_config_path method.

class Sunspot::Rails::Server
# overwriting this method to add FileHandler.limit and .count
def logging_config_path
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")
logging_config.puts("java.util.logging.FileHandler.limit=102400")
logging_config.puts("java.util.logging.FileHandler.count=2")
logging_config.flush
logging_config.close
logging_config.path
end
end
end