Welcome

Wheresoever you go, go with all your heart. (Confucius)

6/01/2011

log4cplus - Logging library to C++ such as log4j

log4cplus is the excellent logging library to C++ such as log4j.
You can see at log4cplus.sourceforge.net.
Current version is 1.0.4, released on January 2011.

I tested this library on Visual studio 2005.
It is based on Win32 platform, so you can easily build it.
The following example is to save logging information into a specified log file.


 <Code Example>

#include <log4cplus/logger.h>
#include <log4cplus/configurator.h>
#include <log4cplus/fileappender.h>
using namespace log4cplus;
int main()
{
    SharedAppenderPtr myAppender(new FileAppender("LogFile.log"));
    BasicConfigurator config;
    config.configure();
    logger = Logger::getInstance("main");
    logger.addAppender(myAppender);
    logger.setLogLevel(ALL_LOG_LEVEL);
    LOG4CPLUS_WARN(logger, "Warning Test");
    return 0;
}

No comments: