Hi
I am new to c++. I want to develop a transaction management system. in that case i have to maintain log files. I got the an API for log file creating. It is log4cpp. I installed it. I am using eclipse indigo for c++. I try with fallowing example code.
#include <stdio.h>
#include <log4cpp/Category.hh>
#include <log4cpp/FileAppender.hh>
#include <log4cpp/SimpleLayout.hh>
#define LOGFILE "/home/user/test.log"
int main()
{
/*Setting up Appender, layout and Category*/
log4cpp::Appender *appender = new log4cpp::FileAppender("FileAppender",LOGFILE);
log4cpp::Layout *layout = new log4cpp::SimpleLayout();
log4cpp::Category& category = log4cpp::Category::getInstance("Category");
appender->setLayout(layout);
category.setAppender(appender);
category.setPriority(log4cpp::Priority::INFO);
/*The actual logging*/
category.info("This is for tracing the flow");
category.notice("This is to notify certain events");
category.warn("This is to generate certain warnings");
}
I got this code from
http://joysofprogramming.com/simple-log4cpp-example/
But in eclipse it's not work. And "log4cpp::Appender *appender = new log4cpp::FileAppender("FileAppender",LOGFILE);" line and other lines are indicate red colour. the compiler message is "undefined reference to `log4cpp::FileAppender::FileAppender(std::basic_string<char, std::char_traits<char>,
std::allocator<char> > const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool,
unsigned int)'". Please help me. I don't know how to config this. the preprocessor including not indicate red colour.
Thank you.