Log For Ruby

LogForRuby (Log4r) is a logging library written in RubyLanguage

A comprehensive and flexible logging library... It features a hierarchical logging system of any number of levels, custom level names, logger inheritance, multiple output destinations, execution tracing, custom formatting, thread safety, XML and YAML configuration, and more. Log4r is an adherent to the philosophy of logging using simple print statements. What Log4r adds to this philosophy is a flexible way of controlling the information being logged. Log information can be sent to any kind of destination and with varying degrees of importance. Log4r is designed so that logging statements can remain in production code with almost no extra computational cost. Maintained by Colby Gutierrez-Kraybill

http://log4r.rubyforge.org/

It can be easily used in a program written in Ruby. There is plenty of documentation and some examples included in the distribution.


Example (from http://log4r.rubyforge.org/manual.html#outofbox )

  require 'log4r'
  include Log4r

# create a logger named 'mylog' that logs to stdout mylog = Logger.new 'mylog' mylog.outputters = Outputter.stdout

# Now we can log. def do_log(log) log.debug "This is a message with level DEBUG" log.info "This is a message with level INFO" log.warn "This is a message with level WARN" log.error "This is a message with level ERROR" log.fatal "This is a message with level FATAL" end do_log(mylog)

Output

  DEBUG mylog: This is a message with level DEBUG
   INFO mylog: This is a message with level INFO
   WARN mylog: This is a message with level WARN
  ERROR mylog: This is a message with level ERROR
  FATAL mylog: This is a message with level FATAL


See also LogForJava LogForJavaVsRuby LogForCpp PatternsForLoggingDiagnosticMessages


CategoryRuby CategoryLogging


EditText of this page (last edited December 28, 2010) or FindPage with title or text search