log4cpp::NDC - Online Linux Manual PageSection : 3
Updated : 4 Aug 2014
Source : Version 1.0
Note : log4cpp
NAMElog4cpp::NDC − The NDC class implements nested diagnostic contexts as defined by Neil Harrison in the article 'Patterns for Logging
Diagnostic Messages' part of the book '<i>Pattern Languages of
Program Design 3</i>' edited by Martin et al.
SYNOPSIS
#include <NDC.hh>
Classesstruct DiagnosticContext
Public Typestypedef std::vector< DiagnosticContext > ContextStack
Public Member FunctionsNDC ()
virtual ~NDC ()
virtual void _clear ()
virtual ContextStack * _cloneStack ()
virtual const std::string & _get () const
virtual size_t _getDepth () const
virtual void _inherit (ContextStack *stack)
virtual std::string _pop ()
virtual void _push (const std::string &message)
virtual void _setMaxDepth (int maxDepth)
Static Public Member Functionsstatic void clear ()
Clear any nested disgnostic information if any. static ContextStack * cloneStack ()
Clone the diagnostic context for the current thread. static const std::string & get ()
Get the current diagnostic context string. static size_t getDepth ()
Get the current nesting depth of this diagnostic context. static void inherit (ContextStack *stack)
static std::string pop ()
Clients should call this method before leaving a diagnostic context. static void push (const std::string &message)
Push new diagnostic context information for the current thread. static void setMaxDepth (int maxDepth)
Set the maximum nesting depth for the current NDC. static NDC & getNDC ()
Return the NDC for the current thread.
Public AttributesContextStack _stack
Detailed DescriptionThe NDC class implements nested diagnostic contexts as defined by Neil Harrison in the article 'Patterns for Logging
Diagnostic Messages' part of the book '<i>Pattern Languages of
Program Design 3</i>' edited by Martin et al. 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-simulatanously. 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 affect the NDC of the current thread only. NDCs of other threads remain unaffected. To build an NDC one uses the push operation. Simply put, • Contexts can be nested. • When entering a context, call NDC.push. As a side effect, if there is no nested diagnostic context for the current thread, this method will create it. • When leaving a context, call NDC.pop. There is no penalty for forgetting to match each push operation with a corresponding pop, except the obvious mismatch between the real application context and the context set in the NDC. Custom Layouts may include the nested diagnostic context for the current thread in log messages, without any user intervention. Hence, even if a server is serving multiple clients simultaneously, the logs emanating from the same code (belonging to the same category) can still be distinguished because each client request will have a different NDC tag. Unfortunately, unlike Java, C++ does not have platform independent multithreading support. Therefore, currently log4cpp is not multithread aware, it implicitly assumes only one thread exists, the main process thread.
Member Typedef Documentation
typedef std::vector<DiagnosticContext> log4cpp::NDC::ContextStack
Constructor & Destructor Documentation
log4cpp::NDC::NDC ()
log4cpp::NDC::~NDC () [virtual]
Member Function Documentation
void log4cpp::NDC::_clear () [virtual]
NDC::ContextStack * log4cpp::NDC::_cloneStack () [virtual]
const std::string & log4cpp::NDC::_get () const [virtual]
size_t log4cpp::NDC::_getDepth () const [virtual]
void log4cpp::NDC::_inherit (NDC::ContextStack * stack) [virtual]
std::string log4cpp::NDC::_pop () [virtual]
void log4cpp::NDC::_push (const std::string & message) [virtual]
void log4cpp::NDC::_setMaxDepth (int maxDepth) [virtual]
void log4cpp::NDC::clear () [static]Clear any nested disgnostic information if any. This method is useful in cases where the same thread can be potentially used over and over in different unrelated contexts. This method is equivalent to calling the setMaxDepth method with a zero maxDepth argument.
NDC::ContextStack * log4cpp::NDC::cloneStack () [static]Clone the diagnostic context for the current thread. Internally a diagnostic context is represented as a stack. A given thread can supply the stack (i.e. diagnostic context) to a child thread so that the child can inherit the parent thread's diagnostic context. The child thread uses the inherit method to inherit the parent's diagnostic context. Returns: Stack A clone of the current thread's diagnostic context.
const std::string & log4cpp::NDC::get () [static]Get the current diagnostic context string. Returns: the context string.
size_t log4cpp::NDC::getDepth () [static]Get the current nesting depth of this diagnostic context. Returns: the nesting depth
NDC & log4cpp::NDC::getNDC () [static]Return the NDC for the current thread. Returns: the NDC for the current thread
void log4cpp::NDC::inherit (NDC::ContextStack * stack) [static]
std::string log4cpp::NDC::pop () [static]Clients should call this method before leaving a diagnostic context. The returned value is the value that was pushed last. If no context is available, then the empty string '' is returned. Returns: String The innermost diagnostic context.
void log4cpp::NDC::push (const std::string & message) [static]Push new diagnostic context information for the current thread. The contents of the message parameter is determined solely by the client. Parameters: message The new diagnostic context information.
void log4cpp::NDC::setMaxDepth (int maxDepth) [static]Set the maximum nesting depth for the current NDC. Curently NDCs do not enforce a maximum depth and consequentially this method has no effect. Parameters: maxDepth the maximum nesting depth
Member Data Documentation
ContextStack log4cpp::NDC::_stack
AuthorGenerated automatically by Doxygen for log4cpp from the source code. 0
Johanes Gumabo
Data Size : 36,881 byte
man-log4cpp::NDC.3Build : 2024-12-05, 20:55 :
Visitor Screen : x
Visitor Counter ( page / site ) : 4 / 191,721
Visitor ID : :
Visitor IP : 18.117.168.40 :
Visitor Provider : AMAZON-02 :
Provider Position ( lat x lon ) : 39.962500 x -83.006100 : x
Provider Accuracy Radius ( km ) : 1000 :
Provider City : Columbus :
Provider Province : Ohio , : ,
Provider Country : United States :
Provider Continent : North America :
Visitor Recorder : Version :
Visitor Recorder : Library :
Online Linux Manual Page : Version : Online Linux Manual Page - Fedora.40 - march=x86-64 - mtune=generic - 24.12.05
Online Linux Manual Page : Library : lib_c - 24.10.03 - march=x86-64 - mtune=generic - Fedora.40
Online Linux Manual Page : Library : lib_m - 24.10.03 - march=x86-64 - mtune=generic - Fedora.40
Data Base : Version : Online Linux Manual Page Database - 24.04.13 - march=x86-64 - mtune=generic - fedora-38
Data Base : Library : lib_c - 23.02.07 - march=x86-64 - mtune=generic - fedora.36
Very long time ago, I have the best tutor, Wenzel Svojanovsky . If someone knows the email address of Wenzel Svojanovsky , please send an email to johanes_gumabo@yahoo.co.id .
If error, please print screen and send to johanes_gumabo@yahoo.co.id
Under development. Support me via PayPal.