我正在我的项目中实现log4cpp。查看我在项目中实现的Logger类。它在class Earthquake(object):
...
@classmethod
def from_string(cls, strline):
return cls(*myfunc(strline))
文件中定义的函数doConfigure(initfile)
中崩溃。更具体地说,在函数调用log4cpp的PropertyConfiguratorImpl.cpp
文件中调用_properties.load(in)
:
Propertices.cpp
下面是我的记录器类。它在我的项目中实现
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
..................
}
这是我的log4cpp.property文件:
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);
}
};
感谢任何帮助。