Stein Dekker Stein Dekker - 2 months ago 7
Ruby Question

How to format ruby logger?

How do you format the ruby logger?

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