log4cplus in VC++

854 views Asked by At

How I can add log4cplus Framework to an existing project under VC++ ? When i try to do it I receive linker errors. I don't how to fix it. Thanks herzl

2

There are 2 answers

2
Michael Aaron Safyan On

In your project configuration, you need to add the library to your linker settings. While I'm here, though, let me briefly evangelize the google-glog library (which Google uses for its own logging). You can find documentation for it on the Google Logging (GLog) Documentation page. Unlike Log4Cxx, which requires you to create various loggers all over the place, GLog is a little bit simpler to use. Example:

LOG(ERROR) << "An error occurred.";
LOG(DFATAL) << "This will kill the program in debug mode, but not regular mode.";

It's not necessary to instantiate "LOG", "ERROR", or "DFATAL" in the above. They are just there. It also includes some various assertion macros like CHECK, CHECK_NOTNULL, etc. which will check that a particular condition is true, and then LOG(FATAL) with a useful error message if it is the case.

0
Sharath On

I started evaluating log4cplus yesterday. I downloaded and built the library under VC2010 without any trouble. But when you have to link with your own code, it becomes a little tricky since the lib and dll files are scattered all over. I edited the property pages to alter the output directory so that I can find all the debug libs and dlls in one directory and release libs and dlls in another.

Also, for the log4cplus_dll library, name of the lib is different from the dll. I fixed that in the project property. Now I am able to link properly and run it.