Rotating logs; what postrotate should I use?
I'm rotating redmines logs with logrotate. Redmine continues writing to the renamed files; what should I use for postrotate?
Restart works off course, but seems a little overkill...?
That really depends what middleware you are using to serve redmine (mongrel, thin, passenger, fcgi, …?), but I'd rather recommend using the "rails" way than to use logrotate. Have a look at the Logger docs http://www.ruby-doc.org/stdlib/libdoc/logger/rdoc/, especially the
new method with which you can define sizes and/or rotate times, this then goes in your
environment.rb (or specific environment files).
My config looks like this:
# tail -n 1 config/environments/production.rb config.logger = Logger.new(config.log_path, 7, 1048576)
I had a problem when I tried adding the following line as suggested:
config.logger = Logger.new(config.log_path, 7, 1048576)I tried adding the line (separately) to
With the addition, my production.log behaves as though the log level is set to :debug (tons of logging results). This is the case even if I set the config.log level to :warn, :info or :error (in any of the above .rb files).
Is anyone facing the same problem?
You have to state the log level after switching to the new logger, i.e. something like:
config.logger = Logger.new(config.log_path, 7, 1048576) config.logger.level = Logger::INFO
should work. If that solves your problem, please open a new ticket so that we can update the docs? Thanks.
Yes, your fix works! Will open the ticket as requested.
Actually I did tried setting the log level before I posted my problem, only that I did it wrongly by writing
config.log_level = :info
config.logger.level = Logger::INFO
I had thought using the syntax given in config/environment would work, didn't know there's a difference.
# Force all environments to use the same logger level # (by default production uses :info, the others :debug) # config.log_level = :debug