Index: include/log4cxx/helpers/objectptr.h =================================================================== --- include/log4cxx/helpers/objectptr.h (revision 330560) +++ include/log4cxx/helpers/objectptr.h (working copy) @@ -87,6 +87,7 @@ { this->p->releaseRef(); } + this->p = 0; } // Operators Index: src/charsetencoder.cpp =================================================================== --- src/charsetencoder.cpp (revision 330560) +++ src/charsetencoder.cpp (working copy) @@ -464,6 +464,14 @@ CharsetEncoderPtr CharsetEncoder::getDefaultEncoder() { static CharsetEncoderPtr encoder(createDefaultEncoder()); + // + // if invoked after static variable destruction + // (if logging is called in the destructor of a static object) + // then create a new decoder. + // + if (encoder == 0) { + return createDefaultEncoder(); + } return encoder; } Index: src/charsetdecoder.cpp =================================================================== --- src/charsetdecoder.cpp (revision 330560) +++ src/charsetdecoder.cpp (working copy) @@ -433,6 +433,14 @@ CharsetDecoderPtr CharsetDecoder::getDefaultDecoder() { static CharsetDecoderPtr decoder(createDefaultDecoder()); + // + // if invoked after static variable destruction + // (if logging is called in the destructor of a static object) + // then create a new decoder. + // + if (decoder == 0) { + return createDefaultDecoder(); + } return decoder; }