• Advertisement
Sign in to follow this  

Problem with singleton logger in dlls

This topic is 4479 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello, i wrote a log class and used the singleton pattern for it. The class ist in a static lib In my application i bind the lib and load dynamically several dlls witch also shall use that logger class. The problem is, that each dll is starting a new logger class. But that means, that the logfile is clear everytime when a dll is loaded. Is there a way, that the application and all dlls use just one and always the same logger class?? I tried to use shared memory in the loggers cpp file: #pragma data_seg("LOG") CLog* CLog::m_Logger = NULL; #pragma data_seg() #pragma comment(linker, "/SECTION:LOG,RWS") But it still does not work....any suggestions would be great!!

Share this post


Link to post
Share on other sites
Advertisement
Export the singleton instance from a single DLL. Either specfically make the pointer instance dllexport or wrap it in a function interface that the DLLs access.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement