REQUIREMENT client.cpp.logging |
Type | NEW |
Priority | HIGH |
Status | CLOSED |
Topic | C++ client logging configuration |
Des cription |
XmlBlaster provides for its C++ client library a simple console based logging implementation. Additionally you can configure during compilation to embed the rich featured logging library log4cplus which supports many features, for example rolling log files. If you have already an own logging facility in your project you can code xmlBlaster to redirect all logging output to your own logging implementation. XmlBlaster simple logger
This is the default and automatically compiled if not configured otherwise.
Logging output in different levels is sent to the console. On UNIX the
logging is colored to easily recognize errors. This logger is coded
in the file Log.cpp. Try Embed log4cplus
To simplify life we have added log4cplus
(Apache License) from Tad E. Smith to the xmlBlaster distribution.
All necessary source files are located under
To switch on log4cplus logging you need to compile xmlBlaster with the
XMLBLASTER_COMPILE_LOG4CPLUS_PLUGIN=1and compile as usual with the command build cpp (Windows or Unix).
The log4cplus library is embedded by Log4cplus.cpp if you are curious about details. Lookup of the configuration fileYou can take a copy of the example configuration file
ConfigurationWe are forwarding all xmlBlaster.properties and command line settings to log4cplus, so you could configure everything in xmlBlaster.properties instead of having a separate log4cplus.properties. Command line settings are strongest and overwrite the setting in log4cplus.properties, here we switch on debugging: PublishDemo -log4cplus.rootLogger "DEBUG, STDOUT, R" Configuration variable replacementLog4cplus is extended to do ${xy} variable replacement not only from environment but from itself as well (recursion depth is one): The replacement of the own variables has the recursion depth of one. a=b c=${a} sets 'c' to 'b' but a=b e=${c} c=${a} will set 'e' to '${a}' in the worst case, or depending of the sequence of lookup it could evaluate 'e' to 'b'. Redirect logging to your own logging library
You need to implement two simple C++ abstract classes (a factory and the
logging calls) to redirect all logging output to your own code.
We do this as well for the above
The first interface you need to implement is
I_LogFactory.h
which needs to create instances of your logging library (hidden by class I_LogFactory virtual void initialize(const PropMap& propMap) { propMap_ = propMap; }; virtual I_Log& getLog(const std::string& name="") = 0; virtual void releaseLog(const std::string& name="") = 0; The second interface you need to implement is I_Log.h: class I_Log virtual void info(const std::string &instance, const std::string &text)= 0; virtual void warn(const std::string &instance, const std::string &text)= 0; virtual void error(const std::string &instance, const std::string &text)= 0; virtual void trace(const std::string &instance, const std::string &text)= 0; virtual void call(const std::string &instance, const std::string &text)= 0; virtual std::string usage() const { return ""; }
For example if xmlBlaster logs an INFO message it invokes |
Configure |
NOTE: Configuration parameters are specified on command line (-someValue 17) or in the
xmlBlaster.properties file (someValue=17). See requirement "util.property" for details. |
See API | LogFactory |
See API | Log |
See CODE | Log4cplus |
See | http://log4cplus.sourceforge.net/ |
See | http://logging.apache.org/log4j/docs/manual.html/ |
See REQ | client.cpp.compile |
This page is generated from the requirement XML file xmlBlaster/doc/requirements/client.cpp.logging.xml