1

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.

3
  • Build a debugging version of your application and the log4cpp library and then try to pin-point the issue using a debugger. The above is not enough. Commented Jun 25, 2015 at 4:47
  • thanks for your comment. I am already doing what is suggested by you. The crash point mentioned in my original post is not from my code. It is from log4cpp implementation. What additional info is needed? Commented Jun 25, 2015 at 8:41
  • debug version of the application shows crash at ** log4cpp::PropertyConfigurator::configure(initFileName);** function call with access violation exception. Commented Jun 28, 2015 at 17:59

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.