changeset 101:428784e59dcd

trying to use log4cplus
author jodogne
date Wed, 03 Oct 2012 11:44:46 +0200
parents 27dc762e3dc8
children 7593b57dc1bf
files CMakeLists.txt Core/Logging.cpp Core/Logging.h OrthancServer/DicomProtocol/DicomServer.cpp OrthancServer/Internals/CommandDispatcher.cpp OrthancServer/Internals/DcmtkLogging.cpp OrthancServer/Internals/DcmtkLogging.h OrthancServer/Internals/FindScp.cpp OrthancServer/Internals/MoveScp.cpp OrthancServer/Internals/StoreScp.cpp Resources/CMake/DcmtkConfiguration.cmake Resources/CMake/Log4CPlusConfiguration.cmake UnitTests/main.cpp
diffstat 13 files changed, 125 insertions(+), 82 deletions(-) [+]
line wrap: on
line diff
--- a/CMakeLists.txt	Wed Oct 03 09:33:25 2012 +0200
+++ b/CMakeLists.txt	Wed Oct 03 11:44:46 2012 +0200
@@ -4,6 +4,7 @@
 include(${CMAKE_SOURCE_DIR}/Resources/CMake/AutoGeneratedCode.cmake)
 include(${CMAKE_SOURCE_DIR}/Resources/CMake/DownloadPackage.cmake)
 include(CheckIncludeFiles)
+include(CheckIncludeFileCXX)
 
 SET(STATIC_BUILD ON CACHE BOOL "Static build of the third-party libraries (necessary for Windows)")
 SET(STANDALONE_BUILD OFF CACHE BOOL "Standalone build (necessary for cross-compilation or binary releases)")
@@ -20,7 +21,7 @@
   CHECK_INCLUDE_FILES(uuid/uuid.h HAVE_UUID_H)
 endif()
 
-if (NOT ${HAVE_UUID_H})
+if (NOT HAVE_UUID_H)
   message(FATAL_ERROR "Please install the uuid-dev package")
 endif()
 
@@ -39,6 +40,7 @@
 
 include(${CMAKE_SOURCE_DIR}/Resources/CMake/BoostConfiguration.cmake)
 include(${CMAKE_SOURCE_DIR}/Resources/CMake/DcmtkConfiguration.cmake)
+include(${CMAKE_SOURCE_DIR}/Resources/CMake/Log4CPlusConfiguration.cmake) # Must be after DcmtkConfiguration
 include(${CMAKE_SOURCE_DIR}/Resources/CMake/GoogleTestConfiguration.cmake)
 include(${CMAKE_SOURCE_DIR}/Resources/CMake/MongooseConfiguration.cmake)
 include(${CMAKE_SOURCE_DIR}/Resources/CMake/ZlibConfiguration.cmake)
@@ -46,7 +48,6 @@
 include(${CMAKE_SOURCE_DIR}/Resources/CMake/JsonCppConfiguration.cmake)
 include(${CMAKE_SOURCE_DIR}/Resources/CMake/LibCurlConfiguration.cmake)
 include(${CMAKE_SOURCE_DIR}/Resources/CMake/LibPngConfiguration.cmake)
-include(${CMAKE_SOURCE_DIR}/Resources/CMake/Log4CPlusConfiguration.cmake)
 
 
 if (${CMAKE_COMPILER_IS_GNUCXX})
@@ -171,6 +172,7 @@
   Core/HttpServer/MongooseServer.cpp
   Core/MultiThreading/BagOfRunnablesBySteps.cpp
   Core/PngWriter.cpp
+  Core/Logging.cpp
   Core/SQLite/Connection.cpp
   Core/SQLite/FunctionContext.cpp
   Core/SQLite/Statement.cpp
@@ -189,6 +191,7 @@
   OrthancServer/DicomProtocol/DicomServer.cpp
   OrthancServer/DicomProtocol/DicomUserConnection.cpp
   OrthancServer/FromDcmtkBridge.cpp
+  OrthancServer/Internals/DcmtkLogging.cpp
   OrthancServer/Internals/CommandDispatcher.cpp
   OrthancServer/Internals/FindScp.cpp
   OrthancServer/Internals/MoveScp.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Core/Logging.cpp	Wed Oct 03 11:44:46 2012 +0200
@@ -0,0 +1,13 @@
+#include "Logging.h"
+
+namespace Orthanc
+{
+  Logger& GetLoggerInstance(const char* package)
+    {
+#if DCMTK_BUNDLES_LOG4CPLUS == 0
+      return Logger::getInstance(package);
+#else
+      return OFLog::getLogger(package);
+#endif
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Core/Logging.h	Wed Oct 03 11:44:46 2012 +0200
@@ -0,0 +1,18 @@
+#pragma once
+
+#if DCMTK_BUNDLES_LOG4CPLUS == 0
+#include <log4cpp/Category.hh>
+#else
+#include <dcmtk/oflog/logger.h>
+#endif
+
+namespace Orthanc
+{
+#if DCMTK_BUNDLES_LOG4CPLUS == 0
+  typedef log4cpp::Category Logger;
+#else
+  typedef OFLogger Logger;
+#endif
+
+  Logger& GetLoggerInstance(const char* package);
+}
--- a/OrthancServer/DicomProtocol/DicomServer.cpp	Wed Oct 03 09:33:25 2012 +0200
+++ b/OrthancServer/DicomProtocol/DicomServer.cpp	Wed Oct 03 11:44:46 2012 +0200
@@ -22,6 +22,7 @@
 
 #include "../../Core/OrthancException.h"
 #include "../../Core/Toolbox.h"
+#include "../Internals/DcmtkLogging.h"
 #include "../Internals/CommandDispatcher.h"
 
 #include <boost/thread.hpp>
@@ -38,12 +39,6 @@
   };
 
 
-  namespace Internals
-  {
-    OFLogger Logger = OFLog::getLogger("dcmtk.apps.storescp");
-  }
-
-
   void DicomServer::ServerThread(DicomServer* server)
   {
     /* Disable "gethostbyaddr" (which results in memory leaks) and use raw IP addresses */
@@ -52,8 +47,8 @@
     /* make sure data dictionary is loaded */
     if (!dcmDataDict.isDictionaryLoaded())
     {
-      OFLOG_WARN(Internals::Logger, "no data dictionary loaded, check environment variable: "
-                 << DCM_DICT_ENVIRONMENT_VARIABLE);
+      LOG4CPP_WARN(Internals::GetLogger(), "no data dictionary loaded, check environment variable: "
+		   DCM_DICT_ENVIRONMENT_VARIABLE);
     }
 
     /* initialize network, i.e. create an instance of T_ASC_Network*. */
@@ -62,12 +57,11 @@
       (NET_ACCEPTOR, OFstatic_cast(int, server->port_), /*opt_acse_timeout*/ 30, &net);
     if (cond.bad())
     {
-      OFString temp_str;
-      OFLOG_ERROR(Internals::Logger, "cannot create network: " << DimseCondition::dump(temp_str, cond));
+      LOG4CPP_ERROR(Internals::GetLogger(), "cannot create network: " + std::string(cond.text()));
       throw OrthancException("Cannot create network");
     }
 
-    OFLOG_WARN(Internals::Logger, "DICOM server started");
+    LOG4CPP_WARN(Internals::GetLogger(), "DICOM server started");
 
     server->started_ = true;
 
@@ -90,15 +84,14 @@
       }
     }
 
-    OFLOG_WARN(Internals::Logger, "DICOM server stopping");
+    LOG4CPP_WARN(Internals::GetLogger(), "DICOM server stopping");
 
     /* drop the network, i.e. free memory of T_ASC_Network* structure. This call */
     /* is the counterpart of ASC_initializeNetwork(...) which was called above. */
     cond = ASC_dropNetwork(&net);
     if (cond.bad())
     {
-      OFString temp_str;
-      OFLOG_ERROR(Internals::Logger, DimseCondition::dump(temp_str, cond));
+      LOG4CPP_ERROR(Internals::GetLogger(), "Error while dropping the network: " + std::string(cond.text()));
     }
   }                           
 
--- a/OrthancServer/Internals/CommandDispatcher.cpp	Wed Oct 03 09:33:25 2012 +0200
+++ b/OrthancServer/Internals/CommandDispatcher.cpp	Wed Oct 03 11:44:46 2012 +0200
@@ -23,9 +23,11 @@
 #include "FindScp.h"
 #include "StoreScp.h"
 #include "MoveScp.h"
+#include "DcmtkLogging.h"
 #include "../../Core/Toolbox.h"
 
 #include <dcmtk/dcmnet/dcasccfg.h>      /* for class DcmAssociationConfiguration */
+#include <boost/lexical_cast.hpp>
 
 static OFBool    opt_rejectWithoutImplementationUID = OFFalse;
 
@@ -34,24 +36,20 @@
 {
   namespace Internals
   {
-    extern OFLogger Logger;
-
-
-
     OFCondition AssociationCleanup(T_ASC_Association *assoc)
     {
       OFString temp_str;
       OFCondition cond = ASC_dropSCPAssociation(assoc);
       if (cond.bad())
       {
-        OFLOG_FATAL(Internals::Logger, DimseCondition::dump(temp_str, cond));
+        LOG4CPP_FATAL(Internals::GetLogger(), std::string(cond.text()));
         return cond;
       }
 
       cond = ASC_destroyAssociation(&assoc);
       if (cond.bad())
       {
-        OFLOG_FATAL(Internals::Logger, DimseCondition::dump(temp_str, cond));
+        LOG4CPP_FATAL(Internals::GetLogger(), std::string(cond.text()));
         return cond;
       }
 
@@ -109,13 +107,13 @@
       // if some kind of error occured, take care of it
       if (cond.bad())
       {
-        OFLOG_ERROR(Internals::Logger, "Receiving Association failed: " << DimseCondition::dump(temp_str, cond));
+        LOG4CPP_ERROR(Internals::GetLogger(), "Receiving Association failed: " + std::string(cond.text()));
         // no matter what kind of error occurred, we need to do a cleanup
         AssociationCleanup(assoc);
         return NULL;
       }
 
-      OFLOG_INFO(Internals::Logger, "Association Received");
+      LOG4CPP_INFO(Internals::GetLogger(), "Association Received");
 
       transferSyntaxes[0] = UID_LittleEndianExplicitTransferSyntax;
       transferSyntaxes[1] = UID_BigEndianExplicitTransferSyntax;
@@ -126,7 +124,7 @@
       cond = ASC_acceptContextsWithPreferredTransferSyntaxes( assoc->params, &knownAbstractSyntaxes[0], knownAbstractSyntaxes.size(), transferSyntaxes, numTransferSyntaxes);
       if (cond.bad())
       {
-        OFLOG_DEBUG(Internals::Logger, DimseCondition::dump(temp_str, cond));
+        LOG4CPP_DEBUG(Internals::GetLogger(), std::string(cond.text()));
         AssociationCleanup(assoc);
         return NULL;
       }
@@ -135,7 +133,7 @@
       cond = ASC_acceptContextsWithPreferredTransferSyntaxes( assoc->params, dcmAllStorageSOPClassUIDs, numberOfAllDcmStorageSOPClassUIDs, transferSyntaxes, numTransferSyntaxes);
       if (cond.bad())
       {
-        OFLOG_DEBUG(Internals::Logger, DimseCondition::dump(temp_str, cond));
+        LOG4CPP_DEBUG(Internals::GetLogger(), std::string(cond.text()));
         AssociationCleanup(assoc);
         return NULL;
       }
@@ -155,11 +153,11 @@
             ASC_REASON_SU_APPCONTEXTNAMENOTSUPPORTED
           };
 
-        OFLOG_INFO(Internals::Logger, "Association Rejected: Bad Application Context Name: " << buf);
+        LOG4CPP_INFO(Internals::GetLogger(), "Association Rejected: Bad Application Context Name: " + std::string(buf));
         cond = ASC_rejectAssociation(assoc, &rej);
         if (cond.bad())
         {
-          OFLOG_DEBUG(Internals::Logger, DimseCondition::dump(temp_str, cond));
+          LOG4CPP_DEBUG(Internals::GetLogger(), std::string(cond.text()));
         }
         AssociationCleanup(assoc);
         return NULL;
@@ -185,9 +183,9 @@
           return NULL;
         }
 
-        std::string callingIP(OFSTRING_GUARD(callingIP_C));
-        std::string callingTitle(OFSTRING_GUARD(callingTitle_C));
-        std::string calledTitle(OFSTRING_GUARD(calledTitle_C));
+        std::string callingIP(/*OFSTRING_GUARD*/(callingIP_C));
+        std::string callingTitle(/*OFSTRING_GUARD*/(callingTitle_C));
+        std::string calledTitle(/*OFSTRING_GUARD*/(calledTitle_C));
         Toolbox::ToUpperCase(callingIP);
         Toolbox::ToUpperCase(callingTitle);
         Toolbox::ToUpperCase(calledTitle);
@@ -231,11 +229,11 @@
             ASC_REASON_SU_NOREASON
           };
 
-        OFLOG_INFO(Internals::Logger, "Association Rejected: No Implementation Class UID provided");
+        LOG4CPP_INFO(Internals::GetLogger(), "Association Rejected: No Implementation Class UID provided");
         cond = ASC_rejectAssociation(assoc, &rej);
         if (cond.bad())
         {
-          OFLOG_DEBUG(Internals::Logger, DimseCondition::dump(temp_str, cond));
+          LOG4CPP_DEBUG(Internals::GetLogger(), std::string(cond.text()));
         }
         AssociationCleanup(assoc);
         return NULL;
@@ -245,13 +243,13 @@
         cond = ASC_acknowledgeAssociation(assoc);
         if (cond.bad())
         {
-          OFLOG_ERROR(Internals::Logger, DimseCondition::dump(temp_str, cond));
+          LOG4CPP_ERROR(Internals::GetLogger(), std::string(cond.text()));
           AssociationCleanup(assoc);
           return NULL;
         }
-        OFLOG_INFO(Internals::Logger, "Association Acknowledged (Max Send PDV: " << assoc->sendPDVLength << ")");
+        LOG4CPP_INFO(Internals::GetLogger(), "Association Acknowledged (Max Send PDV: " + boost::lexical_cast<std::string>(assoc->sendPDVLength) + ")");
         if (ASC_countAcceptedPresentationContexts(assoc->params) == 0)
-          OFLOG_INFO(Internals::Logger, "    (but no valid presentation contexts)");
+          LOG4CPP_INFO(Internals::GetLogger(), "    (but no valid presentation contexts)");
       }
 
       return new CommandDispatcher(server, assoc);
@@ -278,7 +276,7 @@
       // detail information, dump this information
       if (statusDetail != NULL)
       {
-        OFLOG_WARN(Internals::Logger, "Status Detail:" << OFendl << DcmObject::PrintHelper(*statusDetail));
+        //LOG4CPP_WARN(Internals::GetLogger(), "Status Detail:" << OFendl << DcmObject::PrintHelper(*statusDetail));
         delete statusDetail;
       }
 
@@ -349,8 +347,9 @@
         default:
           // we cannot handle this kind of message
           cond = DIMSE_BADCOMMANDTYPE;
-          OFLOG_ERROR(Internals::Logger, "cannot handle command: 0x"
-                      << STD_NAMESPACE hex << OFstatic_cast(unsigned, msg.CommandField));
+          LOG4CPP_ERROR(Internals::GetLogger(), "cannot handle command: 0x"
+			+ boost::lexical_cast<std::string>(hex) 
+			+ boost::lexical_cast<std::string>(msg.CommandField));
           break;
         }
       }
@@ -365,17 +364,17 @@
       {
         if (cond == DUL_PEERREQUESTEDRELEASE)
         {
-          OFLOG_INFO(Internals::Logger, "Association Release");
+          LOG4CPP_INFO(Internals::GetLogger(), "Association Release");
           ASC_acknowledgeRelease(assoc_);
         }
         else if (cond == DUL_PEERABORTEDASSOCIATION)
         {
-          OFLOG_INFO(Internals::Logger, "Association Aborted");
+          LOG4CPP_INFO(Internals::GetLogger(), "Association Aborted");
         }
         else
         {
           OFString temp_str;
-          OFLOG_ERROR(Internals::Logger, "DIMSE failure (aborting association): " << DimseCondition::dump(temp_str, cond));
+          LOG4CPP_ERROR(Internals::GetLogger(), "DIMSE failure (aborting association): " + std::string(cond.text()));
           /* some kind of error so abort the association */
           ASC_abortAssociation(assoc_);
         }
@@ -388,14 +387,14 @@
     OFCondition EchoScp( T_ASC_Association * assoc, T_DIMSE_Message * msg, T_ASC_PresentationContextID presID)
     {
       OFString temp_str;
-      OFLOG_INFO(Internals::Logger, "Received Echo Request");
-      OFLOG_DEBUG(Internals::Logger, DIMSE_dumpMessage(temp_str, msg->msg.CEchoRQ, DIMSE_INCOMING, NULL, presID));
+      LOG4CPP_INFO(Internals::GetLogger(), "Received Echo Request");
+      //LOG4CPP_DEBUG(Internals::GetLogger(), DIMSE_dumpMessage(temp_str, msg->msg.CEchoRQ, DIMSE_INCOMING, NULL, presID));
 
       /* the echo succeeded !! */
       OFCondition cond = DIMSE_sendEchoResponse(assoc, presID, &msg->msg.CEchoRQ, STATUS_Success, NULL);
       if (cond.bad())
       {
-        OFLOG_ERROR(Internals::Logger, "Echo SCP Failed: " << DimseCondition::dump(temp_str, cond));
+        LOG4CPP_ERROR(Internals::GetLogger(), "Echo SCP Failed: " + std::string(cond.text()));
       }
       return cond;
     }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/OrthancServer/Internals/DcmtkLogging.cpp	Wed Oct 03 11:44:46 2012 +0200
@@ -0,0 +1,12 @@
+#include "DcmtkLogging.h"
+
+namespace Orthanc
+{
+  namespace Internals
+  {
+    Logger& GetLogger()
+    {
+      return GetLoggerInstance("Dcmtk");
+    }
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/OrthancServer/Internals/DcmtkLogging.h	Wed Oct 03 11:44:46 2012 +0200
@@ -0,0 +1,9 @@
+#include "../../Core/Logging.h"
+
+namespace Orthanc
+{
+  namespace Internals
+  {
+    Logger& GetLogger();
+  }
+}
--- a/OrthancServer/Internals/FindScp.cpp	Wed Oct 03 09:33:25 2012 +0200
+++ b/OrthancServer/Internals/FindScp.cpp	Wed Oct 03 11:44:46 2012 +0200
@@ -22,6 +22,7 @@
 
 #include "../FromDcmtkBridge.h"
 #include "../ToDcmtkBridge.h"
+#include "DcmtkLogging.h"
 #include "../../Core/OrthancException.h"
 
 #include <dcmtk/dcmdata/dcfilefo.h>
@@ -33,12 +34,6 @@
 
 namespace Orthanc
 {
-  namespace Internals
-  {
-    extern OFLogger Logger;
-  }
-
-
   namespace
   {  
     struct FindScpData
@@ -77,7 +72,7 @@
         catch (OrthancException& e)
         {
           // Internal error!
-          OFLOG_ERROR(Internals::Logger, "IFindRequestHandler Failed: " << e.What());
+          LOG4CPP_ERROR(Internals::GetLogger(), "IFindRequestHandler Failed: " + std::string(e.What()));
           response->DimseStatus = STATUS_FIND_Failed_UnableToProcess;
           *responseIdentifiers = NULL;   
           return;
@@ -125,7 +120,7 @@
     if (cond.bad())
     {
       OFString temp_str;
-      OFLOG_ERROR(Internals::Logger, "Find SCP Failed: " << DimseCondition::dump(temp_str, cond));
+      LOG4CPP_ERROR(Internals::GetLogger(), "Find SCP Failed: " + std::string(cond.text()));
     }
 
     return cond;
--- a/OrthancServer/Internals/MoveScp.cpp	Wed Oct 03 09:33:25 2012 +0200
+++ b/OrthancServer/Internals/MoveScp.cpp	Wed Oct 03 11:44:46 2012 +0200
@@ -25,6 +25,7 @@
 #include "../FromDcmtkBridge.h"
 #include "../ToDcmtkBridge.h"
 #include "../../Core/OrthancException.h"
+#include "DcmtkLogging.h"
 
 #include <dcmtk/dcmdata/dcfilefo.h>
 #include <dcmtk/dcmdata/dcmetinf.h>
@@ -35,12 +36,6 @@
 
 namespace Orthanc
 {
-  namespace Internals
-  {
-    extern OFLogger Logger;
-  }
-
-
   namespace
   {  
     struct MoveScpData
@@ -87,7 +82,7 @@
         catch (OrthancException& e)
         {
           // Internal error!
-          OFLOG_ERROR(Internals::Logger, "IMoveRequestHandler Failed: " << e.What());
+          LOG4CPP_ERROR(Internals::GetLogger(), "IMoveRequestHandler Failed: " + std::string(e.What()));
           response->DimseStatus = STATUS_MOVE_Failed_UnableToProcess;
           return;
         }
@@ -116,7 +111,7 @@
         catch (OrthancException& e)
         {
           // Internal error!
-          OFLOG_ERROR(Internals::Logger, "IMoveRequestHandler Failed: " << e.What());
+          LOG4CPP_ERROR(Internals::GetLogger(), "IMoveRequestHandler Failed: " + std::string(e.What()));
           response->DimseStatus = STATUS_MOVE_Failed_UnableToProcess;
           return;
         }
@@ -167,7 +162,7 @@
     if (cond.bad())
     {
       OFString temp_str;
-      OFLOG_ERROR(Internals::Logger, "Move SCP Failed: " << DimseCondition::dump(temp_str, cond));
+      LOG4CPP_ERROR(Internals::GetLogger(), "Move SCP Failed: " + std::string(cond.text()));
     }
 
     return cond;
--- a/OrthancServer/Internals/StoreScp.cpp	Wed Oct 03 09:33:25 2012 +0200
+++ b/OrthancServer/Internals/StoreScp.cpp	Wed Oct 03 11:44:46 2012 +0200
@@ -23,6 +23,7 @@
 #include "../FromDcmtkBridge.h"
 #include "../ToDcmtkBridge.h"
 #include "../../Core/OrthancException.h"
+#include "DcmtkLogging.h"
 
 #include <dcmtk/dcmdata/dcfilefo.h>
 #include <dcmtk/dcmdata/dcmetinf.h>
@@ -33,12 +34,6 @@
 
 namespace Orthanc
 {
-  namespace Internals
-  {
-    extern OFLogger Logger;
-  }
-
-
   namespace
   {  
     struct StoreCallbackData
@@ -68,9 +63,14 @@
       DcmOutputBufferStream ob(&buffer[0], s);
 
       dataSet->transferInit();
+
+#if 0
       OFCondition c = dataSet->write(ob, xfer, encodingType, NULL,
                                      /*opt_groupLength*/ EGL_recalcGL,
                                      /*opt_paddingType*/ EPD_withoutPadding);
+#endif
+      OFCondition c = dataSet->write(ob, xfer, encodingType);
+
       dataSet->transferEnd();
       if (c.good())
       {
@@ -155,7 +155,7 @@
 
             if (SaveToMemoryBuffer(*imageDataSet, buffer) < 0)
             {
-              OFLOG_ERROR(Internals::Logger, "cannot write DICOM file to memory");
+              LOG4CPP_ERROR(Internals::GetLogger(), "cannot write DICOM file to memory");
               rsp->DimseStatus = STATUS_STORE_Refused_OutOfResources;
             }
           }
@@ -171,7 +171,7 @@
             // which SOP class and SOP instance ?
             if (!DU_findSOPClassAndInstanceInDataSet(*imageDataSet, sopClass, sopInstance, /*opt_correctUIDPadding*/ OFFalse))
             {
-              //OFLOG_ERROR(Internals::Logger, "bad DICOM file: " << fileName);
+              //LOG4CPP_ERROR(Internals::GetLogger(), "bad DICOM file: " << fileName);
               rsp->DimseStatus = STATUS_STORE_Error_CannotUnderstand;
             }
             else if (strcmp(sopClass, req->AffectedSOPClassUID) != 0)
@@ -191,7 +191,7 @@
               catch (OrthancException& e)
               {
                 rsp->DimseStatus = STATUS_STORE_Refused_OutOfResources;
-                OFLOG_ERROR(Internals::Logger, "Exception while storing DICOM: " << e.What());
+                LOG4CPP_ERROR(Internals::GetLogger(), "Exception while storing DICOM: " + std::string(e.What()));
               }
             }
           }
@@ -224,7 +224,10 @@
     // intialize some variables
     StoreCallbackData callbackData;
     callbackData.handler = &handler;
-    callbackData.modality = dcmSOPClassUIDToModality(req->AffectedSOPClassUID, "UNKNOWN");
+    callbackData.modality = dcmSOPClassUIDToModality(req->AffectedSOPClassUID/*, "UNKNOWN"*/);
+    if (callbackData.modality == NULL)
+      callbackData.modality = "UNKNOWN";
+
     callbackData.affectedSOPInstanceUID = req->AffectedSOPInstanceUID;
     callbackData.messageID = req->MessageID;
     if (assoc && assoc->params)
@@ -257,7 +260,7 @@
     if (cond.bad())
     {
       OFString temp_str;
-      OFLOG_ERROR(Logger, "Store SCP Failed: " << DimseCondition::dump(temp_str, cond));
+      LOG4CPP_ERROR(GetLogger(), "Store SCP Failed: " + std::string(cond.text()));
     }
 
     // return return value
--- a/Resources/CMake/DcmtkConfiguration.cmake	Wed Oct 03 09:33:25 2012 +0200
+++ b/Resources/CMake/DcmtkConfiguration.cmake	Wed Oct 03 11:44:46 2012 +0200
@@ -58,19 +58,18 @@
   include(FindDCMTK)
 
   include_directories(${DCMTK_INCLUDE_DIR})
-  link_libraries(${DCMTK_LIBRARIES} oflog ofstd wrap)
+  link_libraries(${DCMTK_LIBRARIES} ofstd wrap)
 
   add_definitions(
     -DHAVE_CONFIG_H=1
     )
 
-  message("${DCMTK_DIR}/oflog")
-  
   IF (EXISTS "${DCMTK_DIR}/oflog")
     set(DCMTK_BUNDLES_LOG4CPLUS 1)
+    link_libraries(${DCMTK_LIBRARIES} oflog)
   else()
     set(DCMTK_BUNDLES_LOG4CPLUS 0)
   endif()
 endif()
 
-message("DCMTK includes its own copy of Log4Cplus: ${DCMTK_BUNDLES_LOG4CPLUS}")
+message("Does DCMTK includes its own copy of Log4Cplus: ${DCMTK_BUNDLES_LOG4CPLUS}")
--- a/Resources/CMake/Log4CPlusConfiguration.cmake	Wed Oct 03 09:33:25 2012 +0200
+++ b/Resources/CMake/Log4CPlusConfiguration.cmake	Wed Oct 03 11:44:46 2012 +0200
@@ -51,6 +51,10 @@
   source_group(ThirdParty\\Log4Cplus REGULAR_EXPRESSION ${LOG4CPLUS_SOURCES_DIR}/.*)
 
 else()
-  message(FATAL_ERROR "Dynamic log4cplus")
-  
+  CHECK_INCLUDE_FILE_CXX(log4cpp/FileAppender.hh HAVE_LOG4CPLUS_H)
+  if (NOT HAVE_LOG4CPLUS_H)
+    message(FATAL_ERROR "Please install the liblog4cpp5-dev package")
+  endif()
+
+  link_libraries(log4cpp)
 endif()
--- a/UnitTests/main.cpp	Wed Oct 03 09:33:25 2012 +0200
+++ b/UnitTests/main.cpp	Wed Oct 03 11:44:46 2012 +0200
@@ -281,13 +281,13 @@
 
 
 
+#include "../Core/Logging.h"
+
 #if DCMTK_BUNDLES_LOG4CPLUS == 0
-#include <log4cplus/logger.h>
 #include <log4cplus/consoleappender.h>
 #include <log4cplus/fileappender.h>
 #include <log4cplus/configurator.h>
 #else
-#include <dcmtk/oflog/logger.h>
 #include <dcmtk/oflog/consap.h>
 #include <dcmtk/oflog/fileap.h>
 //#include <dcmtk/oflog/configurator.h>
@@ -298,7 +298,7 @@
 
 TEST(Logger, Basic)
 {
-  LOG4CPLUS_INFO(logger, "I say hello");
+  LOG4CPP_INFO(logger, "I say hello");
 }