私はlog4cxxを使い始めました。 Visual Studio 2005でコンパイルしましたが、警告もエラーもありません。それは、グローバルロガーオブジェクトを破壊しようとしているときに、私は例外を取得するとき、私はアプリを閉じるまで期待通りに動作しますlog4cxxは〜Loggerの例外をスローしています
#includes<...>
...
...
LoggerPtr logger(Logger::getLogger("MyApp"));
void main(...)
{
//some logs here
}
:よう は基本的に見えます。ここ はトレースです:
log4cxx.dll!apr_pool_cleanup_kill(apr_pool_t * p=0xdddddddd, const void * data=0x01cf6158, int (void *)* cleanup_fn=0x10174250) Line 1981 + 0x3 bytes
log4cxx.dll!apr_pool_cleanup_run(apr_pool_t * p=0xdddddddd, void * data=0x01cf6158, int (void *)* cleanup_fn=0x10174250) Line 2025
log4cxx.dll!apr_thread_mutex_destroy(apr_thread_mutex_t * mutex=0x01cf6158) Line 133
log4cxx.dll!log4cxx::helpers::Mutex::~Mutex() Line 57
log4cxx.dll!log4cxx::Logger::~Logger() Line 55 + 0xb bytes
log4cxx.dll!log4cxx::Logger::`vbase destructor'() + 0x19 bytes
log4cxx.dll!log4cxx::Logger::`vector deleting destructor'() + 0x5a bytes
log4cxx.dll!log4cxx::helpers::ObjectImpl::releaseRef() Line 46 + 0x39 bytes
log4cxx.dll!log4cxx::Logger::releaseRef() Line 63
log4cxx.dll!log4cxx::helpers::ObjectPtrT<log4cxx::Logger>::~ObjectPtrT<log4cxx::Logger>() Line 100 + 0x33 bytes
NodeBHeartBeat.exe!`dynamic atexit destructor for 'logger''() + 0x2b bytes
msvcr80d.dll!doexit(int code=0x00000000, int quick=0x00000000, int retcaller=0x00000001) Line 553
msvcr80d.dll!_cexit() Line 413 + 0xb bytes
msvcr80d.dll!__CRTDLL_INIT(void * hDllHandle=0x6c710000, unsigned long dwReason=0x00000000, void * lpreserved=0x00000001) Line 389
msvcr80d.dll!_CRTDLL_INIT(void * hDllHandle=0x6c710000, unsigned long dwReason=0x00000000, void * lpreserved=0x00000001) Line 214 + 0x11 bytes
ntdll.dll!774b9960()
誰もが任意のアイデアなぜこれが起こっているを持っていますか?
class A
{
public:
A()
{
string appPath = getenv("APPDIR");
appPath = appPath + "/" + LOG4CXX_CONFIG_FILE_NAME;
// Load configuration file
DOMConfigurator::configure(appPath.c_str());
m_serviceLogger = Logger::getLogger("tuxedoService");
}
void log()
{
LOG4CXX_ERROR(m_serviceLogger, "This is a Test log");
}
private:
LoggerPtr m_serviceLogger;
};
A a;
int main()
{
a.log();
return 0;
}
あなたはinit()
のように、メンバ関数でコンストラクタを交換する場合、注意、およびログの前にメインでinit()
にお電話ください:クラスの内部であなたのLoggerPtrを置く おかげ