简体   繁体   English

如何在C ++中使用DLL API中的徽标获取日志

[英]How to get log by using logog in DLL API's in C++

How to write log inside DLL API? 如何在DLL API中编写日志?

In my program I am using two threads with one main thread. 在我的程序中,我使用两个线程和一个主线程。 I am initializing: 我正在初始化:

LOGOG_INITIALIZE();

logog::LogFile errFile("log.txt");

Into my main thread and using INFO , ERR in main thread other two threads. 进入我的主线程并在其他两个线程中使用INFOERR My main thread is using C++ DLL API's. 我的主线程正在使用C ++ DLL API。 I am perfectly getting log from main thread and two other running thread but my problem is I am not able to get log from DLL API's flow. 我可以从主线程和其他两个正在运行的线程中获取日志,但是我的问题是我无法从DLL API的流中获取日志。 How to get log by using logog in DLL API's. 如何通过使用DLL API中的徽标获取日志。 I would like to clear here if I am using INFO in DLL API. 我想在这里清除是否在DLL API中使用INFO it is crashing but if I do LOGOG_INITIALIZE(); 它崩溃了,但是如果我执行LOGOG_INITIALIZE(); inside DLL API, INFO executes but does not log anything. 在DLL API中, INFO执行但不记录任何内容。

If i get it correct, your situation is as follows: You have, for example, one application (EXE) which uses a shared library (DLL). 如果我没弄错,您的情况如下:例如,您有一个使用共享库(DLL)的应用程序(EXE)。 From both, the EXE and the DLL, you want to be able to log. 您希望能够同时从EXE和DLL登录。

Last time i checked out the logog library i run in problems with the situation described above. 上次我签出徽标库时,我遇到了上述情况的问题。 Maybe now it is corrected? 也许现在更正了吗?

Under windows (only!), the logog library doesn't export any symbols - it is simply not ready to be used as DLL. 在Windows(仅!)下, 徽标库不导出任何符号-根本不准备用作DLL。 This forces you to build and use logog as static library - which leads to problems with static variables inside the logog library which should exist only once, but in reality are existing as many times as the static library was linked to a module (EXE or DLL). 这会迫使您将徽标作为静态库进行构建和使用-导致徽标库中的静态变量出现问题,该静态变量应该只存在一次,但实际上存在的次数与将静态库链接到模块的次数相同(EXE或DLL) )。

The solution would be to build and use the logog library as DLL. 解决方案是将徽标库作为DLL构建并使用。

Maybe this covers your problem and you may take the effort to export the symbols of the logog library. 也许这可以解决您的问题,并且您可能会尝试导出徽标库的符号。 Or you could get in contact with the library writer. 或者您可以与图书馆作家联系。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM