开发者

log4cplus in VC++

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 开发者_StackOverflow中文版fix it. Thanks herzl


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜