diff options
author | Benjamin Neff <benjamin@coding4coffee.ch> | 2015-05-27 04:34:08 +0300 |
---|---|---|
committer | Dennis Schubert <mail@dennis-schubert.de> | 2015-05-28 02:26:48 +0300 |
commit | 5655eead7c83a5463f01c743642480deea71b9d1 (patch) | |
tree | 986fb236936603878156be4b237866998a131227 /config/logging.rb | |
parent | 62e8f87f2c17c21d641ffe577adfbade8336e4b9 (diff) |
make the logrotation configurable
closes #5994
Diffstat (limited to 'config/logging.rb')
-rw-r--r-- | config/logging.rb | 36 |
1 files changed, 24 insertions, 12 deletions
diff --git a/config/logging.rb b/config/logging.rb index ae5d536fd..77214f7a4 100644 --- a/config/logging.rb +++ b/config/logging.rb @@ -36,18 +36,30 @@ Logging::Rails.configure do |config| ) ) if config.log_to.include? "stdout" - # Configure an appender that will write log events to a file. The file will - # be rolled on a daily basis, and the past 7 rolled files will be kept. - # Older files will be deleted. The default pattern layout is used when - # formatting log events into strings. - Logging.appenders.rolling_file("file", - filename: config.paths["log"].first, - keep: 7, - age: "daily", - truncate: false, - auto_flushing: true, - layout: layout - ) if config.log_to.include? "file" + if config.log_to.include? "file" + # Configure an appender that will write log events to a file. + if AppConfig.environment.logging.logrotate.enable? + # The file will be rolled on a daily basis, and the rolled files will be kept + # the configured number of days. Older files will be deleted. The default pattern + # layout is used when formatting log events into strings. + Logging.appenders.rolling_file("file", + filename: config.paths["log"].first, + keep: AppConfig.environment.logging.logrotate.days.to_i, + age: "daily", + truncate: false, + auto_flushing: true, + layout: layout + ) + else + # No file rolling, use logrotate to roll the logfile. + Logging.appenders.file("file", + filename: config.paths["log"].first, + truncate: false, + auto_flushing: true, + layout: layout + ) + end + end # Setup the root logger with the Rails log level and the desired set of # appenders. The list of appenders to use should be set in the environment |