T
Tim Pease
SYNOPSIS
Logging is a flexible logging library for use in Ruby programs based on the
design of Java's log4j library. It features a hierarchical logging system,
custom level names, multiple output destinations per log event, custom
formatting, and more.
Logging is intended to supersede the orphaned Log4r project.
INSTALL
To install:
$ gem install logging
A tarball is also available on the RubyForge project page:
http://rubyforge.org/projects/logging/
EXAMPLE
require 'rubygems'
require 'logging'
include Logging
log = Logger.new 'test'
log.appenders = Appender.stdout
log.level = 'info'
log.debug 'debug message'
log.info 'informational message'
log.warn 'Danger! Danger! Will Robinson'
log.error {
# ... some very time consuming code goes here
'this log message took a long time to construct'
}
log.fatal 'Die Die Die'
The following lines are printed to STDOUT
INFO test : informational message
WARN test : Danger! Danger! Will Robinson
ERROR test : this log message took a long time to construct
FATAL test : Die Die Die
NOTES
Although Logging is intended to supersede Log4r, it is not a one-to-one
replacement for the Log4r library. Most notably is the difference in name spaces
-- Logging vs. Log4r. Other differences include renaming Log4r::Outputter to
Logging::Appender and renaming Log4r::Formatter to Logging::Layout. These
changes were meant to bring the Logging class names more in line with the Log4j
class names.
This is an alpha release, and as such it is not yet feature complete. Neither
the YAML configuration nor the XML configuration have been incorporated into the
Logging library. Not all the logging appenders have been incorporated into the
Logging library either. If you would like to port any code from Log4r please
contact me (contact info can be found in the gem specification).
Logging is a flexible logging library for use in Ruby programs based on the
design of Java's log4j library. It features a hierarchical logging system,
custom level names, multiple output destinations per log event, custom
formatting, and more.
Logging is intended to supersede the orphaned Log4r project.
INSTALL
To install:
$ gem install logging
A tarball is also available on the RubyForge project page:
http://rubyforge.org/projects/logging/
EXAMPLE
require 'rubygems'
require 'logging'
include Logging
log = Logger.new 'test'
log.appenders = Appender.stdout
log.level = 'info'
log.debug 'debug message'
log.info 'informational message'
log.warn 'Danger! Danger! Will Robinson'
log.error {
# ... some very time consuming code goes here
'this log message took a long time to construct'
}
log.fatal 'Die Die Die'
The following lines are printed to STDOUT
INFO test : informational message
WARN test : Danger! Danger! Will Robinson
ERROR test : this log message took a long time to construct
FATAL test : Die Die Die
NOTES
Although Logging is intended to supersede Log4r, it is not a one-to-one
replacement for the Log4r library. Most notably is the difference in name spaces
-- Logging vs. Log4r. Other differences include renaming Log4r::Outputter to
Logging::Appender and renaming Log4r::Formatter to Logging::Layout. These
changes were meant to bring the Logging class names more in line with the Log4j
class names.
This is an alpha release, and as such it is not yet feature complete. Neither
the YAML configuration nor the XML configuration have been incorporated into the
Logging library. Not all the logging appenders have been incorporated into the
Logging library either. If you would like to port any code from Log4r please
contact me (contact info can be found in the gem specification).