On 7/6/06, LI Daobing <[EMAIL PROTECTED]> wrote:
Hello,
is there any guideline on how to use log4cxx in library?
I tried use it in my library, but it seems does not work. I prepare a
test file in attachment. and when I run it, it crashed. gdb give
following information[1]. please help me, thanks.
I think I made a mistake in previos test file, the C++ does not define
the init order of global static object. so I rewrite the testcase
file(now it does not sounds useful for library). but it still crash,
and gdb give similar info[1].
maybe this is a bug of log4cxx on amd64 platform? or I make a mistake
on how to use log4cxx. Thanks.
[1]
(gdb) bt
#0 0x00002b221c82c536 in
log4cxx::helpers::AppenderAttachableImpl::appendLoopOnAppenders ()
from /usr/lib/liblog4cxx.so.9
#1 0x00002b221c857838 in log4cxx::Logger::callAppenders () from
/usr/lib/liblog4cxx.so.9
#2 0x00002b221c8579a0 in log4cxx::Logger::forcedLog () from
/usr/lib/liblog4cxx.so.9
#3 0x0000000000402534 in main () at log4cxx.t.cpp:13
(gdb)
--
LI Daobing
#include <log4cxx/logger.h>
#include <log4cxx/consoleappender.h>
#include <log4cxx/level.h>
using namespace log4cxx;
int main()
{
ConsoleAppender* app = new ConsoleAppender();
app->setTarget("system.err");
Logger::getLogger("a")->addAppender(app);
Logger::getLogger("a")->setLevel(Level::INFO);
LOG4CXX_ERROR(Logger::getLogger("a"),
"can't open file: %s");
LOG4CXX_ERROR(Logger::getLogger("a.b"),
"can't open file: %s");
return 0;
}