Stein Dekker Stein Dekker - 1 year ago 67
Ruby Question

How to format ruby logger?

How do you format the ruby logger?

Answer Source
logger = Logger.new('nice.log')

logger.formatter = proc do |severity, datetime, progname, msg|
   "NICE: #{msg}\n"
end

logger.info("I like cheese.")

# nice.log:
NICE: I like cheese.