logger (ruby)

apache 项目中的与log4j对应的ruby版为-> log4r
ruby 代码
  1.   log = Logger.new(STDOUT)
    log.level = Logger::WARN

    log.debug("Created logger")
    log.info("Program started")
    log.warn("Nothing to do!")

    begin
    File.each_line(path) do |line|
    unless line =~ /^(\w+) = (.*)$/
    log.error("Line in wrong format: #{line}")
    end
    end
    rescue => err
    log.fatal("Caught exception; exiting")
    log.fatal(err)
    end
      

你可能感兴趣的:(linux,log4j,咨询,Ruby,Rails)