Index: helpers/classlogger.cpp
===================================================================
--- helpers/classlogger.cpp	(revision 16)
+++ helpers/classlogger.cpp	(working copy)
@@ -76,11 +76,16 @@
 									  0,
 									  LogManager::logger(QLatin1String(pObject->metaObject()->className())));
 	    return const_cast<Logger *>(mpLogger);
+#elif QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
+        if (!static_cast<Logger *>(mpLogger))
+             mpLogger.testAndSetOrdered(0,
+                                        LogManager::logger(QLatin1String(pObject->metaObject()->className())));
+        return const_cast<Logger *>(static_cast<Logger *>(mpLogger));
 #else
-	    if (!static_cast<Logger *>(mpLogger))
+        if (!static_cast<Logger *>(mpLogger.loadAcquire()))
 			 mpLogger.testAndSetOrdered(0,
 										LogManager::logger(QLatin1String(pObject->metaObject()->className())));
-	    return const_cast<Logger *>(static_cast<Logger *>(mpLogger));
+        return const_cast<Logger *>(static_cast<Logger *>(mpLogger.loadAcquire()));
 #endif
 	}
 
Index: helpers/initialisationhelper.h
===================================================================
--- helpers/initialisationhelper.h	(revision 16)
+++ helpers/initialisationhelper.h	(working copy)
@@ -37,6 +37,7 @@
 
 #include <QtCore/QAtomicPointer>
 #include <QtCore/QHash>
+#include <QtCore/QString>
 
 #if QT_VERSION >= QT_VERSION_CHECK(4, 4, 0)
 #	ifndef Q_ATOMIC_POINTER_TEST_AND_SET_IS_ALWAYS_NATIVE
@@ -122,20 +123,35 @@
 			}                                                                 \
 			return const_cast<TYPE *>(sp_global_static_##FUNCTION);           \
 		}
+#elif QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
+    #define LOG4QT_GLOBAL_STATIC(TYPE, FUNCTION)                              \
+        static QBasicAtomicPointer<TYPE > sp_global_static_##FUNCTION =       \
+            Q_BASIC_ATOMIC_INITIALIZER(0);                                    \
+        TYPE *FUNCTION()                                                      \
+        {                                                                     \
+            if (!sp_global_static_##FUNCTION)                                 \
+            {                                                                 \
+                TYPE *p_temp = new TYPE;                                      \
+                if (!sp_global_static_##FUNCTION.testAndSetOrdered(0,         \
+                                                                   p_temp))   \
+                    delete p_temp;                                            \
+            }                                                                 \
+            return sp_global_static_##FUNCTION;                               \
+        }
 #else
     #define LOG4QT_GLOBAL_STATIC(TYPE, FUNCTION)                              \
 		static QBasicAtomicPointer<TYPE > sp_global_static_##FUNCTION =       \
 			Q_BASIC_ATOMIC_INITIALIZER(0);                                    \
         TYPE *FUNCTION()                                                      \
         {                                                                     \
-            if (!sp_global_static_##FUNCTION)                                 \
+            if (!sp_global_static_##FUNCTION.loadAcquire())                   \
             {                                                                 \
                 TYPE *p_temp = new TYPE;                                      \
                 if (!sp_global_static_##FUNCTION.testAndSetOrdered(0,         \
 																   p_temp))   \
                     delete p_temp;                                            \
             }                                                                 \
-            return sp_global_static_##FUNCTION;                               \
+            return sp_global_static_##FUNCTION.loadAcquire();                 \
         }
 #endif
 
@@ -195,19 +211,33 @@
 			}                                                                 \
 			return sp_singleton_##TYPE;                                       \
 		}
+#elif QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
+    #define LOG4QT_IMPLEMENT_INSTANCE(TYPE)                                   \
+        static QBasicAtomicPointer<TYPE > sp_singleton_##TYPE =               \
+            Q_BASIC_ATOMIC_INITIALIZER(0);                                    \
+        TYPE *TYPE::instance()                                                \
+        {                                                                     \
+            if (!sp_singleton_##TYPE)                                         \
+            {                                                                 \
+                TYPE *p_temp = new TYPE;                                      \
+                if (!sp_singleton_##TYPE.testAndSetOrdered(0, p_temp))        \
+                    delete p_temp;                                            \
+            }                                                                 \
+            return sp_singleton_##TYPE;                                       \
+        }
 #else
     #define LOG4QT_IMPLEMENT_INSTANCE(TYPE)                                   \
 		static QBasicAtomicPointer<TYPE > sp_singleton_##TYPE =               \
 			Q_BASIC_ATOMIC_INITIALIZER(0);                                    \
         TYPE *TYPE::instance()                                                \
         {                                                                     \
-            if (!sp_singleton_##TYPE)                                         \
+            if (!sp_singleton_##TYPE.loadAcquire())                           \
             {                                                                 \
                 TYPE *p_temp = new TYPE;                                      \
                 if (!sp_singleton_##TYPE.testAndSetOrdered(0, p_temp))        \
                     delete p_temp;                                            \
             }                                                                 \
-            return sp_singleton_##TYPE;                                       \
+            return sp_singleton_##TYPE.loadAcquire();                         \
         }
 #endif
 
Index: helpers/logerror.cpp
===================================================================
--- helpers/logerror.cpp	(revision 16)
+++ helpers/logerror.cpp	(working copy)
@@ -60,9 +60,9 @@
 	
 	
     LOG4QT_GLOBAL_STATIC(ThreadError, thread_error)
+
     
     
-    
 	/**************************************************************************
 	 * Class implementation: LogError
 	 **************************************************************************/
@@ -111,7 +111,11 @@
 				mMessage = QString::fromLatin1(pMessage);
 				break;
 			case CODECFORTR:
+#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
 				mMessage = QTextCodec::codecForTr()->toUnicode(pMessage);
+#else
+                mMessage = QString::fromUtf8(pMessage);
+#endif
 				break;
 			case UNICODEUTF8:
 				mMessage = QString::fromUtf8(pMessage);
@@ -129,7 +133,11 @@
 	
 	QString LogError::translatedMessage() const
 	{
-	    return QCoreApplication::translate(mContext.toLatin1(), mMessage.toUtf8().data(), 0, QCoreApplication::UnicodeUTF8);
+#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
+        return QCoreApplication::translate(mContext.toLatin1(), mMessage.toUtf8().data(), 0, QCoreApplication::UnicodeUTF8);
+#else
+        return QCoreApplication::translate(mContext.toLatin1(), mMessage.toUtf8().data(), 0);
+#endif
 	}
 	
 	
Index: helpers/logerror.h
===================================================================
--- helpers/logerror.h	(revision 16)
+++ helpers/logerror.h	(working copy)
@@ -140,7 +140,7 @@
 	    	 */
 	        CODECFORTR,
 	    	/*! UTF-8 */
-	        UNICODEUTF8,
+            UNICODEUTF8
 	    };
 	    Q_ENUMS(Encoding)
 
Index: helpers/logobject.h
===================================================================
--- helpers/logobject.h	(revision 16)
+++ helpers/logobject.h	(working copy)
@@ -183,7 +183,11 @@
 	{}
 
 	inline int LogObject::referenceCount() const
-	{	return mReferenceCount;	}
+#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
+    {	return mReferenceCount;	}
+#else
+    {	return mReferenceCount.loadAcquire();	}
+#endif
 
 	inline void LogObject::release()
 #if QT_VERSION < QT_VERSION_CHECK(4, 4, 0)
Index: level.cpp
===================================================================
--- level.cpp	(revision 16)
+++ level.cpp	(working copy)
@@ -32,6 +32,7 @@
 #include "log4qt/level.h"
 
 #include <QtCore/QCoreApplication>
+#include <QtCore/QDataStream>
 #include <QtCore/QDebug>
 #include "log4qt/logger.h"
 
Index: logger.h
===================================================================
--- logger.h	(revision 16)
+++ logger.h	(working copy)
@@ -125,18 +125,31 @@
 				}                                                             \
 			return p_logger;                                                  \
 		}
+#elif QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
+    #define LOG4QT_DECLARE_STATIC_LOGGER(FUNCTION, CLASS)                     \
+        static Log4Qt::Logger *FUNCTION()                                     \
+        {                                                                     \
+            static QBasicAtomicPointer<Log4Qt::Logger > p_logger =            \
+                Q_BASIC_ATOMIC_INITIALIZER(0);                                \
+            if (!p_logger)                                                    \
+            {                                                                 \
+                p_logger.testAndSetOrdered(0,                                 \
+                    Log4Qt::Logger::logger( #CLASS ));                        \
+            }                                                                 \
+            return p_logger;                                                  \
+        }
 #else
 	#define LOG4QT_DECLARE_STATIC_LOGGER(FUNCTION, CLASS)                     \
 	    static Log4Qt::Logger *FUNCTION()                                     \
 	    {                                                                     \
 			static QBasicAtomicPointer<Log4Qt::Logger > p_logger =            \
 				Q_BASIC_ATOMIC_INITIALIZER(0);                                \
-	        if (!p_logger)                                                    \
+            if (!p_logger.loadAcquire())                                      \
 	        {                                                                 \
 	        	p_logger.testAndSetOrdered(0,                                 \
 					Log4Qt::Logger::logger( #CLASS ));                        \
             }                                                                 \
-	        return p_logger;                                                  \
+            return p_logger.loadAcquire();                                    \
 	    }
 #endif
 
Index: logmanager.cpp
===================================================================
--- logmanager.cpp	(revision 16)
+++ logmanager.cpp	(working copy)
@@ -188,12 +188,20 @@
 	    if (instance()->mHandleQtMessages)
 	    {
 	        static_logger()->trace("Activate Qt message handling");
-	        instance()->mOldQtMsgHandler = qInstallMsgHandler(qtMessageHandler);
+#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
+            instance()->mOldQtMsgHandler = qInstallMsgHandler(qtMessageHandler);
+#else
+            instance()->mOldQtMsgHandler = qInstallMessageHandler(qtMessageHandler);
+#endif
 	    }
 	    else
 	    {
 	        static_logger()->trace("Deactivate Qt message handling");
-	        qInstallMsgHandler(instance()->mOldQtMsgHandler);
+#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
+            qInstallMsgHandler(instance()->mOldQtMsgHandler);
+#else
+            qInstallMessageHandler(instance()->mOldQtMsgHandler);
+#endif
 	    }
 	}
 	
@@ -363,55 +371,106 @@
         }
     }
     
-    
-	void LogManager::qtMessageHandler(QtMsgType type, const char *pMessage)
-	{
-	    Level level;
-	    switch (type)
-	    {
-	        case QtDebugMsg:
-	            level = Level::DEBUG_INT;
-	            break;
-	        case QtWarningMsg:
-	            level = Level::WARN_INT;
-	            break;
-	        case QtCriticalMsg:
-	            level = Level::ERROR_INT;
-	            break;
-	        case QtFatalMsg:
-	            level = Level::FATAL_INT;
-	            break;
-	        default:
-	            level = Level::TRACE_INT;
-	    }
-	    instance()->qtLogger()->log(level, pMessage);
-	    
-	    // Qt fatal behaviour copied from global.cpp qt_message_output()
-	    // begin {
-	    
-	    if ((type == QtFatalMsg) || 
-	        ((type == QtWarningMsg) && (!qgetenv("QT_FATAL_WARNINGS").isNull())) )
-	    {
+#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
+    void LogManager::qtMessageHandler(QtMsgType type, const char *pMessage)
+    {
+        Level level;
+        switch (type)
+        {
+            case QtDebugMsg:
+                level = Level::DEBUG_INT;
+                break;
+            case QtWarningMsg:
+                level = Level::WARN_INT;
+                break;
+            case QtCriticalMsg:
+                level = Level::ERROR_INT;
+                break;
+            case QtFatalMsg:
+                level = Level::FATAL_INT;
+                break;
+            default:
+                level = Level::TRACE_INT;
+        }
+        instance()->qtLogger()->log(level, pMessage);
+
+        // Qt fatal behaviour copied from global.cpp qt_message_output()
+        // begin {
+
+        if ((type == QtFatalMsg) ||
+            ((type == QtWarningMsg) && (!qgetenv("QT_FATAL_WARNINGS").isNull())) )
+        {
 #if defined(Q_CC_MSVC) && defined(QT_DEBUG) && defined(_DEBUG) && defined(_CRT_ERROR)
-	        // get the current report mode
-	        int reportMode = _CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_WNDW);
-	        _CrtSetReportMode(_CRT_ERROR, reportMode);
-	        int ret = _CrtDbgReport(_CRT_ERROR, __FILE__, __LINE__, QT_VERSION_STR, pMessage);
-	        if (ret == 0  && reportMode & _CRTDBG_MODE_WNDW)
-	            return; // ignore
-	        else if (ret == 1)
-	            _CrtDbgBreak();
+            // get the current report mode
+            int reportMode = _CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_WNDW);
+            _CrtSetReportMode(_CRT_ERROR, reportMode);
+            int ret = _CrtDbgReport(_CRT_ERROR, __FILE__, __LINE__, QT_VERSION_STR, pMessage);
+            if (ret == 0  && reportMode & _CRTDBG_MODE_WNDW)
+                return; // ignore
+            else if (ret == 1)
+                _CrtDbgBreak();
 #endif
-	        
+
 #if defined(Q_OS_UNIX) && defined(QT_DEBUG)
-	        abort(); // trap; generates core dump
+            abort(); // trap; generates core dump
 #else
-	        exit(1); // goodbye cruel world
+            exit(1); // goodbye cruel world
 #endif
-	    }
-	    
-	    // } end
-	}
+        }
+
+        // } end
+    }
+#else
+    void LogManager::qtMessageHandler(QtMsgType type, const QMessageLogContext &context, const QString &message)
+    {
+        Level level;
+        switch (type)
+        {
+            case QtDebugMsg:
+                level = Level::DEBUG_INT;
+                break;
+            case QtWarningMsg:
+                level = Level::WARN_INT;
+                break;
+            case QtCriticalMsg:
+                level = Level::ERROR_INT;
+                break;
+            case QtFatalMsg:
+                level = Level::FATAL_INT;
+                break;
+            default:
+                level = Level::TRACE_INT;
+        }
+        instance()->qtLogger()->log(level, message);
+
+        // Qt fatal behaviour copied from global.cpp qt_message_output()
+        // begin {
+
+        if ((type == QtFatalMsg) ||
+            ((type == QtWarningMsg) && (!qgetenv("QT_FATAL_WARNINGS").isNull())) )
+        {
+#if defined(Q_CC_MSVC) && defined(QT_DEBUG) && defined(_DEBUG) && defined(_CRT_ERROR)
+            // get the current report mode
+            int reportMode = _CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_WNDW);
+            _CrtSetReportMode(_CRT_ERROR, reportMode);
+            int ret = _CrtDbgReport(_CRT_ERROR, __FILE__, __LINE__, QT_VERSION_STR, message.toUtf8().constData());
+            if (ret == 0  && reportMode & _CRTDBG_MODE_WNDW)
+                return; // ignore
+            else if (ret == 1)
+                _CrtDbgBreak();
+#endif
+
+#if defined(Q_OS_UNIX) && defined(QT_DEBUG)
+            abort(); // trap; generates core dump
+#else
+            exit(1); // goodbye cruel world
+#endif
+        }
+
+        // } end
+    }
+#endif
+
 	
 	
 	LogManager *LogManager::mspInstance = 0;
Index: logmanager.h
===================================================================
--- logmanager.h	(revision 16)
+++ logmanager.h	(working copy)
@@ -255,15 +255,26 @@
 		void doConfigureLogLogger();
 		void doStartup();
 		void welcome();
-	    static void qtMessageHandler(QtMsgType type,
-	                                 const char *pMessage);
+#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
+        static void qtMessageHandler(QtMsgType type,
+                                     const char *pMessage);
+#else
+        static void qtMessageHandler(QtMsgType type,
+                                     const QMessageLogContext &context,
+                                     const QString &message);
+#endif
+
 	
 	private:
 	    mutable QMutex mObjectGuard;
 	    LoggerRepository *mpLoggerRepository;
 	    Logger *mpNullLogger;
 	    bool mHandleQtMessages;
-	    QtMsgHandler mOldQtMsgHandler;
+#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
+        QtMsgHandler mOldQtMsgHandler;
+#else
+        QtMessageHandler mOldQtMsgHandler;
+#endif
 	    static LogManager *mspInstance;
 	};
 	
