Project

General

Profile

Rotating logs; what postrotate should I use?

Added by Fredrik Liljegren almost 15 years ago

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...?

/F


Replies (6)

RE: Rotating logs; what postrotate should I use? - Added by Felix Schäfer almost 15 years ago

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)

RE: Rotating logs; what postrotate should I use? - Added by Wicola Lation about 14 years ago

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
  • config/environments/production.rb
  • config/additional_environment.rb
  • config/environment.rb

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?

RE: Rotating logs; what postrotate should I use? - Added by Felix Schäfer about 14 years ago

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.

RE: Rotating logs; what postrotate should I use? - Added by Wicola Lation about 14 years ago

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

instead of

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 

RE: Rotating logs; what postrotate should I use? - Added by bruno paulino over 4 years ago

I am currently running Redmine 4.1.1 at our company and the configuration has changed a little:

# File config/environments/production.rb
# keep the latest 15 files rotating 20MB each
config.logger = ActiveSupport::Logger.new(config.paths['log'].first, shift_age = 15, shift_size = 20 * 1024 * 1024)

RE: Rotating logs; what postrotate should I use? - Added by adrian perez over 3 years ago

bruno paulino wrote:

I am currently running Redmine 4.1.1 at our company and the configuration has changed a little:

[...]

Thanks man! It works perfectly

    (1-6/6)