log4cpp - Unhandled exception and access violation

1

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 ?

c++
log4j
log4cxx
log4cpp
asked on Stack Overflow Jun 8, 2013 by CDT • edited Jun 8, 2013 by CDT

2 Answers

0

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.

answered on Stack Overflow Oct 17, 2013 by Alex InTechno
0

I think you run into this bug ... and it is from 2008.

answered on Stack Overflow Aug 18, 2016 by Zvonimir Vanjak

User contributions licensed under CC BY-SA 3.0