Skip to content

Instantly share code, notes, and snippets.

@ma2gedev
Last active August 29, 2015 14:16
Show Gist options
  • Select an option

  • Save ma2gedev/24f19bae533d986476c3 to your computer and use it in GitHub Desktop.

Select an option

Save ma2gedev/24f19bae533d986476c3 to your computer and use it in GitHub Desktop.
chrono_logger gem の紹介しつつ Rails アプリのロギングを振り返る ref: http://qiita.com/ma2ge/items/1fba78a08e8d3b82b3c2
# cronolog installed in /usr/sbin/
# in config/environments/{development,production}.rb
config.logger = Logger.new(IO.popen("/usr/sbin/cronolog #{config.paths['log'].first}.%Y%m%d", "w"))
# 2015/02/01
logger = Logger.new('logfile', 'daily')
# => logfile is generated
logger.info 'today'
# 2015/02/02
logger.info 'next day'
# => logfile.20150201 is generated
# 2015/02/01
logger = Logger.new(IO.popen("/usr/sbin/cronolog logfile.%Y%m%d", "w"))
logger.info 'today'
# => logfile.20150201 is generated
# 2015/02/02
logger.info 'next day'
# => logfile.20150202 is generated
# in Gemfile
gem 'chrono_logger'
# in config/environments/{development,production}.rb
config.logger = ChronoLogger.new("#{config.paths['log'].first}.%Y%m%d")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment