I am implementing log4cpp im my project. See my Logger class implemented in the project. It is crashing in function doConfigure(initfile)
defined in PropertyConfiguratorImpl.cpp
file. More specifically in function call to _properties.load(in)
call in Propertices.cpp
file of the log4cpp:
void Properties::load(std::istream& in)//_Chcount=0 in the expression value { clear(); std::string fullLine, command; std::string leftSide, rightSide; char line[256]; std::string::size_type length; while (in.getline(line, 256)) { fullLine = line; ................ .................//Remaining code of the function .................. }
Below is my logger class.It is implemented in my project
class MyLogger { public: MyLogger(){} virtual ~MyLogger() { log4cpp::Category::shutdown(); } bool Init(){ try{ std::string initFileName = "log4cpp.property"; if(exists(initFileName.c_str())){//the property file does exist log4cpp::PropertyConfigurator::configure(initFileName); } } catch(log4cpp::ConfigureFailure& f){ std::cout << "Configure Problem" << f.what() << std::endl; return false; } return true; } void LogDebug(std::string message){ log4cpp::Category & myLogger = log4cpp::Category::getInstance("MyLogger"); myLogger.debug(message); } void Loginfo(std::string message){ log4cpp::Category & myLogger = log4cpp::Category::getInstance("MyLogger"); myLogger.info(message); } };
This is my log4cpp.property file:
log4cplus.logger.business=ALL,BUSINESS log4cplus.additivity.business=false log4cplus.appender.STDOUT=log4cplus::ConsoleAppender log4cplus.appender.STDOUT.layout=log4cplus::PatternLayout log4cplus.appender.STDOUT.layout.ConversionPattern=%-6p[%t][%D{%m/%d/%y %H:%M:%S %Q}]%m log4cplus.appender.BUSINESS=log4cplus::RollingFileAppender log4cplus.appender.BUSINESS.File=./all.log log4cplus.appender.BUSINESS.MaxFileSize=5MB log4cplus.appender.BUSINESS.MaxBackupIndex=5 log4cplus.appender.BUSINESS.layout=log4cplus::PatternLayout log4cplus.appender.BUSINESS.layout.ConversionPattern=%-6p[%t] [%D{%m/%d/%y %H:%M:%S %Q}] %m
Any help is appreciated.