NLog includes a header file ( NLogC.h ) and an import library ( NLogC.lib ). They should be used to use the library.
Add the path to the included file (for example, C:\Program Files (x86)\NLog\.NET Framework 4.0\NLogC\include ) to the inclusion path either globally or only for the project. You can specify it in the project properties in the section "Additional inclusion directories" in the section "Configuration Properties", "C / C ++", "General". Add the path to the library file (for example, C:\Program Files (x86)\NLog\.NET Framework 4.0\NLogC\x86 , make sure you select x86 or x64 based on the oriented architecture) in the library path ("Additional library directories "in the" Configuration Properties "," Links "," General ").
Add the NLogC.lib file to the project libraries (add it to the "Additional Dependencies" section "Configuration Properties", "Linker", "Login").
Then you can use the API as follows:
#include <cstdarg> // Needed for va_list type, which NLogC.h requires #include <NLogC.h> int main() { NLog_Info(L"Test", L"TestMessage"); return 0; }
Make sure you put NLogC.dll , NLog.dll and a suitable configuration file in the same directory as your executable file.
Note that this is really for use only when you have built-in components as part of a larger managed application or are moving from native to managed. If your application is pure C ++, there are probably more appropriate native log libraries that do not require CLR loading just for logging.
Sven
source share