title: Logging from library with spdlog
body: <p>I am trying to use <a href="https://github.com/gabime/spdlog" rel="noreferrer">spdlog</a> in a project involving a library under windows.
  I create two loggers. One for the app using the library, one for the library itself.
  The library's logger is created from the app but when the library want to add a message, it crash.</p>
  
  <p>Following is an simplified example.</p>
  
  <p><strong>The library</strong></p>
  
  <p><em>libclass.h</em></p>
  
  <pre><code>#ifndef LIBCLASS_H
  #define LIBCLASS_H
  
  #include &lt;spdlog/spdlog.h&gt;
  
  #ifdef WIN32
  #  ifdef BUILD_APPLIB_SHARED
  #    define APPLIB_EXPORT __declspec(dllexport)
  #  else
  #    define APPLIB_EXPORT
  #  endif //BUILD_APPLIB_SHARED
  #else
  #  define APPLIB_EXPORT
  #endif // WIN32
  
  class APPLIB_EXPORT LibClass
  {
  public:
      LibClass();
      ~LibClass();
  
      static std::string loggerName();
  
      void testLog();
  
  private:
      std::shared_ptr&lt;spdlog::logger&gt; m_logger;
  };
  
  #endif //LIBCLASS_H
  </code></pre>
  
  <p><em>libclass.cpp</em></p>
  
  <pre><code>#include "libclass.h"
  
  const std::string myLoggerName = "lib_logger";
  
  LibClass::LibClass()
  {
      m_logger = spdlog::get(myLoggerName);
  }
  
  LibClass::~LibClass()
  { }
  
  std::string LibClass::loggerName()
  {
      return myLoggerName;
  }
  
  void LibClass::testLog()
  {
      m_logger-&gt;info("Log from library");
  }
  </code></pre>
  
  <p><strong>The application</strong></p>
  
  <p><em>main.cpp</em></p>
  
  <pre><code>#include &lt;spdlog/spdlog.h&gt;
  #include &lt;applib/libclass.h&gt;
  
  void logtest()
  {
      auto logger = spdlog::get("app_logger");
      logger-&gt;info("Log from application");
  }
  
  int main(int argc, char *argv[])
  {
      // create loggers
      auto appLogger = spdlog::stdout_logger_mt("app_logger");
      auto libLogger = spdlog::stdout_logger_mt(LibClass::loggerName());
  
      // log from app
      logtest();
  
      // log from lib
      LibClass lc;
      lc.testLog();
  
      return 0;
  }
  </code></pre>