How to rotate, cancel, or disable logging with Sunspot Solr Rubygem?

I had a lot of experience finding Sunspot Solr for Ruby on Rails, however its log files are growing incredibly large, and I can't find a way to either rotate , redefine or disable these logs (except with very hacker methods that I would prefer not to chase) .

I have a sunspot.yml file in config / where I tried setting the log_level flags to SEVERE strong>, however this did not have any effect.

I tried using the standard Logger.config methods, but just posted my development log for newly created files.

I would really appreciate any suggestions you can offer.

+5
source share
5 answers

This is a bit late, but it looks like it is now being processed inside config / sunspot.yml:

production: solr: hostname: thorn port: 8983 log_level: WARNING min_memory: 512M max_memory: 1G solr_home: /u/solr 
+4
source

In the console, this will disable all entries for me:

 Sunspot::Rails::LogSubscriber.logger.level = 4 ActiveRecord::Base.logger.level = 4 Rails.logger.level = 4 

My versions of Gem:

  • sunspot (2.0.0.pre.130115)
  • sunspot_rails (2.0.0.pre.130115)
  • sunspot_solr (2.0.0.pre.130115)
+5
source

You are looking for the Solr logging.properties file to customize the behavior of the Java container log. Sunspot uses Jetty for an embedded instance of Solr. The Solr quiz contains instructions for setting up logging.properties in Jetty at http://wiki.apache.org/solr/LoggingInDefaultJettySetup .

You may need to review the source code for Sunspot rake tasks to determine the best place to enter your own logging.properties . I guess an interesting question would be to go up to the Sunspot mailing list for a potential patch for Sunspot.

+1
source

Currently, the log_level level is not being processed correctly. The fix is ​​on Github , which is version 2.x.

You can wait for the next gem release. And if you do not and are not afraid of risk, you can use the following in the Gemfile:

 # use selectively gem 'sunspot_rails', :git => "git://github.com/sunspot/sunspot.git", :require => "sunspot_rails" gem 'sunspot_solr', :git => "git://github.com/sunspot/sunspot.git", :require => "sunspot_solr" 

I am using logrotate Linux:

 /home/path/log/*.log { su username pwd daily missingok rotate 7 delaycompress notifempty copytruncate } 
+1
source

My monkey fixed the corresponding file in sunspot_solr to solve this problem.

This code is not strong enough to survive in the backchitecting / refactoring mode executed directly in the sunspot_solr stone, so I recommend blocking the version of sunspot_solr gem to version 1.3.0 to succeed.

You can leave the following in your project. We use it in a Rails project and placed it in 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 
0
source

Source: https://habr.com/ru/post/911528/


All Articles