Module Log4r
In: lib/log4r/MDC.rb
lib/log4r/repository.rb
lib/log4r/GDC.rb
lib/log4r/lib/drbloader.rb
lib/log4r/lib/xmlloader.rb
lib/log4r/logevent.rb
lib/log4r/yamlconfigurator.rb
lib/log4r/logserver.rb
lib/log4r/outputter/staticoutputter.rb
lib/log4r/outputter/outputter.rb
lib/log4r/outputter/emailoutputter.rb
lib/log4r/outputter/rollingfileoutputter.rb
lib/log4r/outputter/scribeoutputter.rb
lib/log4r/outputter/outputterfactory.rb
lib/log4r/outputter/udpoutputter.rb
lib/log4r/outputter/remoteoutputter.rb
lib/log4r/outputter/consoleoutputters.rb
lib/log4r/outputter/datefileoutputter.rb
lib/log4r/outputter/fileoutputter.rb
lib/log4r/outputter/syslogoutputter.rb
lib/log4r/outputter/iooutputter.rb
lib/log4r/configurator.rb
lib/log4r/staticlogger.rb
lib/log4r/base.rb
lib/log4r/loggerfactory.rb
lib/log4r/logger.rb
lib/log4r/formatter/patternformatter.rb
lib/log4r/formatter/formatter.rb
lib/log4r/formatter/log4jxmlformatter.rb
lib/log4r/config.rb
lib/log4r/NDC.rb
lib/log4r/version.rb

NDC

The NDC class implements a copy of the Nested Diagnostic Context, which is part of the Apache Log4j library. Nested Diagnostic Contexts were derived from Neil Harrison‘s article on "Patterns for Logging Diagnostic Messages", part of the book "Pattern Languages of Program Design 3" edited by Martin et al.

NDCs in Log4r are thread safe.

NDCs in log4r are close enough to NDCs in Log4j that I include its documentation directly:

… A Nested Diagnostic Context, or NDC in short, is an instrument to distinguish interleaved log output from different sources. Log output is typically interleaved when a server handles multiple clients near-simultaneously.

Interleaved log output can still be meaningful if each log entry from different contexts had a distinctive stamp. This is where NDCs come into play.

Note that NDCs are managed on a per thread basis. NDC operations such as push, pop(), clear(), getDepth() and setMaxDepth(int) affect the NDC of the current thread only. NDCs of other threads remain unaffected. …

An important difference between NDCs in Log4r vs Log4j is that you do not have to called NDC.remove() when exiting a thread.

This class will automatically create Thread specific storage for the current thread on the first call to any of its methods, i.e.

  NDC.push( "client accept" );

New threads may inherit the NDC of the parent thread by making use of the clone_stack() and inherit() methods. By default, the NDC is not inherited automatically. This is unlike MDCs, which will inherit from the main thread.

Other Info

Version:$Id$
Author:Colby Gutierrez-Kraybill <colby(at)astro.berkeley.edu>

Classes and Modules

Class Log4r::BasicFormatter
Class Log4r::ConfigError
Class Log4r::Configurator
Class Log4r::DateFileOutputter
Class Log4r::DefaultFormatter
Class Log4r::EmailOutputter
Class Log4r::FileOutputter
Class Log4r::Formatter
Class Log4r::GDC
Class Log4r::IOOutputter
Class Log4r::Log4jXmlFormatter
Class Log4r::Log4rTools
Class Log4r::LogEvent
Class Log4r::LogServer
Class Log4r::Logger
Class Log4r::MDC
Class Log4r::NDC
Class Log4r::ObjectFormatter
Class Log4r::Outputter
Class Log4r::PatternFormatter
Class Log4r::RemoteOutputter
Class Log4r::RollingFileOutputter
Class Log4r::RootLogger
Class Log4r::ScribeOutputter
Class Log4r::SimpleFormatter
Class Log4r::StderrOutputter
Class Log4r::StdoutOutputter
Class Log4r::SyslogOutputter
Class Log4r::UDPOutputter
Class Log4r::YamlConfigurator

Constants

MDCNAME = "log4rMDC"
MDCNAMEMAXDEPTH = "log4rMDCMAXDEPTH"
GDCNAME = "log4rGDC"
HAVE_ROMP = true
HAVE_ROMP = false
HAVE_REXML = true
HAVE_REXML = false
SYSLOGNAMES = Hash.new
ALL = 0
LNAMES = ['ALL']
NDCNAME = "log4rNDC"
NDCNAMEMAXDEPTH = "log4rNDCMAXDEPTH"
NDCDEFAULTMAXDEPTH = 256
Log4rVersion = [1, 1, 10].join '.'
VERSION = Log4rVersion

[Validate]