一、工程的部分
1. 下载了log4cplus-2.0.5的代码
2. 在log4cplus-2.0.5文件夹里面,挨着msvc14,新建了msvc15
3. 新建一个vs2017 windows console application , log4Demo
4. 将log4plus涉及的project拷贝到msvc15,诸如:
log4cplus.props
log4cplus.vcxproj
log4cplus_debug.props
log4cplus_release.props
log4cplus_static.props
log4cplusS.vcxproj
5. 增加已有的project
solution -> add -> existing project -> log4cplus
solution -> add -> existing project -> log4cplusS
6. Character set
Character set 调整为 'Use Multi-byte character set'
7 include
c++ -> general -> addtional include directories -> add
../../include;../../catch/single_include/catch2;
8. preprocessor
c++ -> preprocessor -> Preprocessor definitions -> add
LOG4CPLUS_BUILD_DLL;_MBCS;
9. addtional library directories
linker -> general -> addtional library directories -> add
$(SolutionDir)$(Platform)in.$(Configuration)
10. input
linker -> input -> addtional dependencies -> add
log4cplusd.lib
11. output directory
general -> output directory -> $(SolutionDir)$(PlatformName)in.$(Configuration)
二、代码的部分
log4cplus::Initializer initializer;
log4cplus::BasicConfigurator config;
config.configure();
log4cplus::Logger logger = log4cplus::Logger::getInstance(
LOG4CPLUS_TEXT("main"));
LOG4CPLUS_WARN(logger, LOG4CPLUS_TEXT("Hello, World!"));
参考文献:
https://sourceforge.net/p/log4cplus/wiki/CodeExamples/