Configuring log4cpp (Simple)
Posted by Joys of Programming on in C/C++
If you want to see how log4cpp works with the basic configuration, there is a log4cpp::BasicConfigurator. It adds a FileAppender which logs the output to standard output and uses a BasicLayout.
#include <stdio.h>
#include <log4cpp/Category.hh>
#include <log4cpp/BasicConfigurator.hh>
using namespace std;
int main()
{
/*Simple Setting up Appender, layout and Category*/
log4cpp::BasicConfigurator::configure();
log4cpp::Category& category = log4cpp::Category::getInstance("Category");
category.info("This is for tracing the flow");
category.notice("This is to notify certain events");
category.warn("This is to generate certain warnings");
}
On executing this program, you will get the following output on the terminal
1263318825 INFO Category : This is for tracing the flow 1263318825 NOTICE Category : This is to notify certain events 1263318825 WARN Category : This is to generate certain warnings
Comments: