activemq-cpp-3.6.0
|
There is a single global LogManager object that is used to maintain a set of shared state about Loggers and log services. More...
#include <src/main/decaf/util/logging/LogManager.h>
Public Member Functions | |
virtual | ~LogManager () |
bool | addLogger (Logger *logger) |
Add a named logger. | |
Logger * | getLogger (const std::string &name) |
Retrieves or creates a new Logger using the name specified a new logger inherits the configuration of the logger's parent if there is no configuration data for the logger. | |
int | getLoggerNames (const std::vector< std::string > &names) |
Gets a list of known Logger Names from this Manager, new loggers added while this method is in progress are not garunteed to be in the list. | |
void | setProperties (const util::Properties &properties) |
Sets the Properties this LogManager should use to configure its loggers. | |
const util::Properties & | getProperties () const |
Gets a reference to the Logging Properties used by this logger. | |
std::string | getProperty (const std::string &name) |
Gets the value of a named property of this LogManager. | |
void | addPropertyChangeListener (PropertyChangeListener *listener) |
Adds a change listener for LogManager Properties, adding the same instance of a change event listener does nothing. | |
void | removePropertyChangeListener (PropertyChangeListener *listener) |
Removes a properties change listener from the LogManager, if the listener is not found of the param is NULL this method returns silently. | |
void | readConfiguration () |
Reinitialize the logging properties and reread the logging configuration. | |
void | readConfiguration (decaf::io::InputStream *stream) |
Reinitialize the logging properties and reread the logging configuration from the given stream, which should be in decaf.util.Properties format. | |
void | reset () |
Reset the logging configuration. |
Static Public Member Functions | |
static LogManager & | getLogManager () |
Get the global LogManager instance. |
Protected Member Functions | |
LogManager () | |
Constructor, hidden to protect against direct instantiation. | |
LogManager (const LogManager &manager) | |
Copy Constructor. | |
void | operator= (const LogManager &manager) |
Assignment operator. |
Friends | |
class | decaf::lang::Runtime |
There is a single global LogManager object that is used to maintain a set of shared state about Loggers and log services.
This LogManager object:
The global LogManager object can be retrieved using LogManager::getLogManager(). The LogManager object is created during class initialization and cannot subsequently be changed.
***TODO**** By default, the LogManager reads its initial configuration from a properties file "lib/logging.properties" in the JRE directory. If you edit that property file you can change the default logging configuration for all uses of that JRE.
In addition, the LogManager uses two optional system properties that allow more control over reading the initial configuration:
These two properties may be set via the Preferences API, or as command line property definitions to the "java" command, or as system property definitions passed to JNI_CreateJavaVM.
If the "java.util.logging.config.class" property is set, then the property value is treated as a class name. The given class will be loaded, an object will be instantiated, and that object's constructor is responsible for reading in the initial configuration. (That object may use other system properties to control its configuration.) The alternate configuration class can use readConfiguration(InputStream) to define properties in the LogManager.
If "decaf.util.logging.config.class" property is not set, then the "decaf.util.logging.config.file" system property can be used to specify a properties file (in decaf.util.Properties format). The initial logging configuration will be read from this file.
If neither of these properties is defined then, as described above, the LogManager will read its initial configuration from a properties file "lib/logging.properties" in the working directory.
The properties for loggers and Handlers will have names starting with the dot-separated name for the handler or logger. ***TODO****
The global logging properties may include:
Loggers are organized into a naming hierarchy based on their dot separated names. Thus "a.b.c" is a child of "a.b", but "a.b1" and a.b2" are peers.
All properties whose names end with ".level" are assumed to define log levels for Loggers. Thus "foo.level" defines a log level for the logger called "foo" and (recursively) for any of its children in the naming hierarchy. Log Levels are applied in the order they are defined in the properties file. Thus level settings for child nodes in the tree should come after settings for their parents. The property name ".level" can be used to set the level for the root of the tree.
All methods on the LogManager object are multi-thread safe.
|
virtual |
|
protected |
Constructor, hidden to protect against direct instantiation.
|
protected |
Copy Constructor.
manager | the Manager to copy |
bool decaf::util::logging::LogManager::addLogger | ( | Logger * | logger | ) |
Add a named logger.
This does nothing and returns false if a logger with the same name is already registered.
The Logger factory methods call this method to register each newly created Logger.
logger | The new Logger instance to add to this LogManager. |
NullPointerException | if logger is NULL. |
IllegalArgumentException | if the logger has no name. |
void decaf::util::logging::LogManager::addPropertyChangeListener | ( | PropertyChangeListener * | listener | ) |
Adds a change listener for LogManager Properties, adding the same instance of a change event listener does nothing.
listener | The PropertyChangeListener to add (can be NULL). |
int decaf::util::logging::LogManager::getLoggerNames | ( | const std::vector< std::string > & | names | ) |
Gets a list of known Logger Names from this Manager, new loggers added while this method is in progress are not garunteed to be in the list.
names | STL Vector to hold string logger names. |
|
static |
Get the global LogManager instance.
|
inline |
Gets a reference to the Logging Properties used by this logger.
std::string decaf::util::logging::LogManager::getProperty | ( | const std::string & | name | ) |
Gets the value of a named property of this LogManager.
name | The name of the Property to retrieve. |
|
protected |
Assignment operator.
manager | the manager to assign from |
void decaf::util::logging::LogManager::readConfiguration | ( | ) |
Reinitialize the logging properties and reread the logging configuration.
The same rules are used for locating the configuration properties as are used at startup. So normally the logging properties will be re-read from the same file that was used at startup.
Any log level definitions in the new configuration file will be applied using Logger.setLevel(), if the target Logger exists.
A PropertyChangeEvent will be fired after the properties are read.
IOException | if an I/O error occurs. |
void decaf::util::logging::LogManager::readConfiguration | ( | decaf::io::InputStream * | stream | ) |
Reinitialize the logging properties and reread the logging configuration from the given stream, which should be in decaf.util.Properties format.
A PropertyChangeEvent will be fired after the properties are read.
Any log level definitions in the new configuration file will be applied using Logger.setLevel(), if the target Logger exists.
stream | The InputStream to read the Properties from. |
NullPointerException | if stream is NULL. |
IOException | if an I/O error occurs. |
void decaf::util::logging::LogManager::removePropertyChangeListener | ( | PropertyChangeListener * | listener | ) |
Removes a properties change listener from the LogManager, if the listener is not found of the param is NULL this method returns silently.
listener | The PropertyChangeListener to remove from the listeners set. |
void decaf::util::logging::LogManager::reset | ( | ) |
Reset the logging configuration.
For all named loggers, the reset operation removes and closes all Handlers and (except for the root logger) sets the level to INHERIT. The root logger's level is set to Level::INFO.
void decaf::util::logging::LogManager::setProperties | ( | const util::Properties & | properties | ) |
Sets the Properties this LogManager should use to configure its loggers.
Once set a properties change event is fired.
properties | Pointer to read the configuration from |
|
friend |