简体   繁体   English

log4cpp-未处理的异常和访问冲突

[英]log4cpp - Unhandled exception and access violation

Here is some example code I read from some tutorial: 这是我从一些教程中读取的一些示例代码:

int main(int argc, char* argv[])
{
    log4cpp::OstreamAppender* osAppender = new log4cpp::OstreamAppender("osAppender", &cout);
    osAppender->setLayout(new log4cpp::BasicLayout());

    log4cpp::Category& root = log4cpp::Category::getRoot();
    root.addAppender(osAppender);
    root.setPriority(log4cpp::Priority::DEBUG);

    root.error("Hello log4cpp in a Error Message!");
    root.warn("Hello log4cpp in a Warning Message!");

    log4cpp::Category::shutdown(); 
    getchar();
    return 0;
}

Error report: 错误报告:

Unhandled exception at 0x76fe15de of log4cpp_Test.exe: 0xC0000005: Access violation wile reading 0x00000024  

What might have caused the error ? 是什么引起了错误?

The code which you have posted is ok. 您发布的代码是可以的。 It is compiled and run well. 它已编译并运行良好。 Are you sure that you have no additional code beside that posted one? 您确定除了已发布的代码之外,没有其他代码了吗? The problem might be caused by just few additional lines. 该问题可能是由少量额外的行引起的。

It looks like somewhere NULL pointer is dereferenced, which causes the access violation. 好像在某个地方取消引用了NULL指针,这会导致访问冲突。

I think you run into this bug ... and it is from 2008. 我认为您遇到了这个错误...这是从2008年开始的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM