Apache Log4cxx  Version 1.5.0
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
log4cxx::Hierarchy Class Reference

This class is specialized in retrieving loggers by name and also maintaining the logger hierarchy. More...

#include <hierarchy.h>

Inheritance diagram for log4cxx::Hierarchy:

Public Member Functions

  ~Hierarchy ()
 
void  addHierarchyEventListener (const spi::HierarchyEventListenerPtr &listener) override
 
void  removeHierarchyEventListener (const spi::HierarchyEventListenerPtr &listener)
  Remove a previously added HierarchyEventListener.
 
void  ensureIsConfigured (std::function< void()> configurator) override
  Call configurator if not yet configured.
 
void  clear ()
  This call will clear all logger definitions from the internal hashtable.
 
void  emitNoAppenderWarning (const Logger *logger) override
 
LoggerPtr  exists (const LogString &name) override
  Check if the named logger exists in the hierarchy.
 
void  setThreshold (const LogString &levelStr) override
  The string form of setThreshold .
 
void  setThreshold (const LevelPtr &newLevel) override
  Enable logging for logging requests with level newLevel or higher.
 
void  fireAddAppenderEvent (const Logger *logger, const Appender *appender) override
 
void  fireRemoveAppenderEvent (const Logger *logger, const Appender *appender) override
 
LevelPtr  getThreshold () const override
  Returns a Level representation of the enable state.
 
LoggerPtr  getLogger (const LogString &name) override
  Retrieve the name Logger instance using the default factory to create it if required.
 
LoggerPtr  getLogger (const LogString &name, const spi::LoggerFactoryPtr &factory) override
  Retrieve the name Logger instance using factory to create it if required.
 
LoggerList  getCurrentLoggers () const override
  Returns all the currently defined loggers in this hierarchy as a LoggerList.
 
LoggerPtr  getRootLogger () const override
  Get the root of this hierarchy.
 
bool  isDisabled (int level) const override
  This method will return true if this repository is disabled for level object passed as parameter and false otherwise.
 
void  resetConfiguration () override
  Reset all values contained in this hierarchy instance to their default.
 
void  shutdown () override
  Used by subclasses to add a renderer to the hierarchy passed as parameter.
 
virtual bool  isConfigured () override
 
virtual void  setConfigured (bool configured) override
 
void  updateChildren (const Logger *parent)
  Refresh the threshold in children of parent.
 
void  clearAppenders ()
 
void  addAppender (AppenderPtr appender)
 
bool  removeLogger (const LogString &name, bool ifNotUsed=true)
  Remove the name Logger from the hierarchy.
 
- Public Member Functions inherited from log4cxx::spi::LoggerRepository
virtual  ~LoggerRepository ()
 
virtual void  addHierarchyEventListener (const HierarchyEventListenerPtr &listener)=0
  Add a HierarchyEventListener event to the repository.
 
virtual void  ensureIsConfigured (std::function< void()> configurator)=0
  Call configurator if not yet configured.
 
virtual bool  isDisabled (int level) const =0
  Is the repository disabled for a given level? The answer depends on the repository threshold and the level parameter.
 
virtual void  setThreshold (const LevelPtr &level)=0
  Set the repository-wide threshold.
 
virtual void  setThreshold (const LogString &val)=0
  Another form of setThreshold accepting a string parameter instead of a Level .
 
virtual void  emitNoAppenderWarning (const Logger *logger)=0
 
virtual LevelPtr  getThreshold () const =0
  Get the repository-wide threshold.
 
virtual LoggerPtr  getLogger (const LogString &name)=0
  Retrieve the name Logger instance.
 
virtual LoggerPtr  getLogger (const LogString &name, const spi::LoggerFactoryPtr &factory)=0
  Retrieve the name Logger instance.
 
virtual LoggerPtr  getRootLogger () const =0
 
virtual LoggerPtr  exists (const LogString &name)=0
 
virtual void  shutdown ()=0
 
virtual LoggerList  getCurrentLoggers () const =0
 
virtual void  fireAddAppenderEvent (const Logger *logger, const Appender *appender)
 
virtual void  fireRemoveAppenderEvent (const Logger *logger, const Appender *appender)
 
virtual void  resetConfiguration ()=0
 
virtual bool  isConfigured ()=0
 
virtual void  setConfigured (bool configured)=0
 
- Public Member Functions inherited from log4cxx::helpers::Object
virtual  ~Object ()
 
virtual const helpers::ClassgetClass () const =0
 
virtual bool  instanceof (const Class &clazz) const =0
 
virtual const void *  cast (const Class &clazz) const =0
 

Static Public Member Functions

static HierarchyPtr  create ()
 

Detailed Description

This class is specialized in retrieving loggers by name and also maintaining the logger hierarchy.

The casual user does not have to deal with this class directly.

The structure of the logger hierarchy is maintained by the getLogger method. The hierarchy is such that children link to their parent but parents do not have any pointers to their children. Moreover, loggers can be instantiated in any order, in particular descendant before ancestor.

In case a descendant is created before a particular ancestor, then it creates a provision node for the ancestor and adds itself to the provision node. Other descendants of the same ancestor add themselves to the previously created provision node.

Constructor & Destructor Documentation

◆  ~Hierarchy()

log4cxx::Hierarchy::~Hierarchy ( )

Member Function Documentation

◆  addAppender()

void log4cxx::Hierarchy::addAppender ( AppenderPtr  appender )

◆  addHierarchyEventListener()

void log4cxx::Hierarchy::addHierarchyEventListener ( const spi::HierarchyEventListenerPtr &  listener )
override

◆  clear()

void log4cxx::Hierarchy::clear ( )

This call will clear all logger definitions from the internal hashtable.

Invoking this method will irrevocably mess up the logger hierarchy.

You should really know what you are doing before invoking this method.

◆  clearAppenders()

void log4cxx::Hierarchy::clearAppenders ( )

◆  create()

static HierarchyPtr log4cxx::Hierarchy::create ( )
static

◆  emitNoAppenderWarning()

void log4cxx::Hierarchy::emitNoAppenderWarning ( const Loggerlogger )
overridevirtual

Implements log4cxx::spi::LoggerRepository.

◆  ensureIsConfigured()

void log4cxx::Hierarchy::ensureIsConfigured ( std::function< void()>  configurator )
overridevirtual

Call configurator if not yet configured.

Implements log4cxx::spi::LoggerRepository.

◆  exists()

LoggerPtr log4cxx::Hierarchy::exists ( const LogStringname )
overridevirtual

Check if the named logger exists in the hierarchy.

If so return its reference, otherwise returns null.

Parameters
name The name of the logger to search for.

Implements log4cxx::spi::LoggerRepository.

◆  fireAddAppenderEvent()

void log4cxx::Hierarchy::fireAddAppenderEvent ( const Loggerlogger,
const Appenderappender 
)
overridevirtual

Reimplemented from log4cxx::spi::LoggerRepository.

◆  fireRemoveAppenderEvent()

void log4cxx::Hierarchy::fireRemoveAppenderEvent ( const Loggerlogger,
const Appenderappender 
)
overridevirtual

Reimplemented from log4cxx::spi::LoggerRepository.

◆  getCurrentLoggers()

LoggerList log4cxx::Hierarchy::getCurrentLoggers ( ) const
overridevirtual

Returns all the currently defined loggers in this hierarchy as a LoggerList.

The root logger is not included in the returned LoggerList.

Implements log4cxx::spi::LoggerRepository.

◆  getLogger() [1/2]

LoggerPtr log4cxx::Hierarchy::getLogger ( const LogStringname )
overridevirtual

Retrieve the name Logger instance using the default factory to create it if required.

If a logger of that name already exists, then it will be returned. Otherwise, a new logger will be instantiated and then linked with its existing ancestors as well as children.

Parameters
name The name of the logger to retrieve.

Implements log4cxx::spi::LoggerRepository.

◆  getLogger() [2/2]

LoggerPtr log4cxx::Hierarchy::getLogger ( const LogStringname,
const spi::LoggerFactoryPtrfactory 
)
overridevirtual

Retrieve the name Logger instance using factory to create it if required.

If a logger of that name already exists, then it will be returned. Otherwise, a new logger will be instantiated by the factory parameter and linked with its existing ancestors as well as children.

Parameters
name The name of the logger to retrieve.
factory The factory that will make the new logger instance.

Implements log4cxx::spi::LoggerRepository.

◆  getRootLogger()

LoggerPtr log4cxx::Hierarchy::getRootLogger ( ) const
overridevirtual

Get the root of this hierarchy.

Implements log4cxx::spi::LoggerRepository.

◆  getThreshold()

LevelPtr log4cxx::Hierarchy::getThreshold ( ) const
overridevirtual

Returns a Level representation of the enable state.

Implements log4cxx::spi::LoggerRepository.

◆  isConfigured()

virtual bool log4cxx::Hierarchy::isConfigured ( )
overridevirtual

Implements log4cxx::spi::LoggerRepository.

◆  isDisabled()

bool log4cxx::Hierarchy::isDisabled ( int  level ) const
overridevirtual

This method will return true if this repository is disabled for level object passed as parameter and false otherwise.

See also the setThreshold method.

Implements log4cxx::spi::LoggerRepository.

◆  removeHierarchyEventListener()

void log4cxx::Hierarchy::removeHierarchyEventListener ( const spi::HierarchyEventListenerPtr &  listener )

Remove a previously added HierarchyEventListener.

◆  removeLogger()

bool log4cxx::Hierarchy::removeLogger ( const LogStringname,
bool  ifNotUsed = true 
)

Remove the name Logger from the hierarchy.

Note: The name Logger must be retrieved from the hierarchy after any subsequent configuration file change for the newly loaded settings to be used.

Parameters
name The logger to remove.
ifNotUsed If true and use_count() indicates there are other references, do not remove the Logger and return false.
Returns
true if name Logger was removed from the hierarchy.

◆  resetConfiguration()

void log4cxx::Hierarchy::resetConfiguration ( )
overridevirtual

Reset all values contained in this hierarchy instance to their default.

This removes all appenders from all categories, sets the level of all non-root categories to null, sets their additivity flag to true and sets the level of the root logger to DEBUG. Moreover, message disabling is set its default "off" value.

Existing categories are not removed. They are just reset.

This method should be used sparingly and with care as it will block all logging until it is completed.

Implements log4cxx::spi::LoggerRepository.

◆  setConfigured()

virtual void log4cxx::Hierarchy::setConfigured ( bool  configured )
overridevirtual

Implements log4cxx::spi::LoggerRepository.

◆  setThreshold() [1/2]

void log4cxx::Hierarchy::setThreshold ( const LevelPtrnewLevel )
overridevirtual

Enable logging for logging requests with level newLevel or higher.

By default all levels are enabled.

Parameters
newLevel The minimum level of logging requests that are sent to appenders.

Implements log4cxx::spi::LoggerRepository.

◆  setThreshold() [2/2]

void log4cxx::Hierarchy::setThreshold ( const LogStringlevelStr )
overridevirtual

The string form of setThreshold .

Implements log4cxx::spi::LoggerRepository.

◆  shutdown()

void log4cxx::Hierarchy::shutdown ( )
overridevirtual

Used by subclasses to add a renderer to the hierarchy passed as parameter.

Shutting down a hierarchy will safely close and remove all appenders in all categories including the root logger.

Some appenders such as XMLSocketAppender and AsyncAppender need to be closed before the application exists. Otherwise, pending logging events might be lost.

The shutdown method is careful to close nested appenders before closing regular appenders. This is allows configurations where a regular appender is attached to a logger and again to a nested appender.

Implements log4cxx::spi::LoggerRepository.

◆  updateChildren()

void log4cxx::Hierarchy::updateChildren ( const Loggerparent )

Refresh the threshold in children of parent.


The documentation for this class was generated from the following file:

AltStyle によって変換されたページ (->オリジナル) /