Skip to content

Instantly share code, notes, and snippets.

@muraoka-edo
Last active August 29, 2015 14:06
Show Gist options
  • Save muraoka-edo/e9efb1ee84a84a1b1107 to your computer and use it in GitHub Desktop.
Save muraoka-edo/e9efb1ee84a84a1b1107 to your computer and use it in GitHub Desktop.
[Ruby] logger
#!/usr/bin/env ruby
# coding: utf-8
require 'logger'
tmpl = 'hogehoge'
# logfile: '/tmp/test.log' logrotate: 'daily'
logger = Logger.new('/tmp/test.log', 'daily')
# logfile: '/tmp/test.log' logrotate: '10Mib/7lotate(1current+6backup)'
# logger = Logger.new('/tmp/test.log', 7, 10*1024*1024)
logger.progname = 'MyApp'
logger.info "#{tmpl} test log"
logger.close
#-----
# $ cat /tmp/test.log
# # Logfile created on 2014-09-27 22:20:38 +0900 by logger.rb/31641
# I, [2014-09-27T23:03:54.373422 #7093] INFO -- MyApp: hogehoge test log
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment