log4cpp crashing while loading properties file

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-08 04:26:55

问题


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.

来源:https://stackoverflow.com/questions/31029569/log4cpp-crashing-while-loading-properties-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!