I am getting error in c++ programm while using log4cxx

4.1k views Asked by At

I am getting error in c++ program while using log4cxx. The error message is:

error:Please initialize the log4cxx system properly

Please help to resolve,

Thanks in advance.

1

There are 1 answers

0
MartinStettner On

AFAIR you have to configure the log4cxx system at the beginning of your program, e.g. using a BasicConfigurator as shown in this Short introduction to Apache log4cxx:

#include "log4cxx/logger.h"
#include "log4cxx/basicconfigurator.h"
#include "log4cxx/helpers/exception.h"

using namespace log4cxx;
using namespace log4cxx::helpers;

LoggerPtr logger(Logger::getLogger("MyApp"));

int main(int argc, char **argv)
{
  // Set up a simple configuration that logs on the console.
  BasicConfigurator::configure();

  LOG4CXX_INFO(logger, "Entering application.");
  // ...
  return 0;
}

HTH Martin