log4cpp 在cef 项目中的应用

LOG4CPP下载与编译

Log4cpp是一个开源的C++类库,它提供了在C++程序中使用日志和跟踪调试的功能。使用log4cpp,可以很便利地将日志或者跟踪调试信息写入字符流、内存字符串队列、文件、回滚文件、调试器、Windows日志、本地syslog和远程syslog服务器中。

下载地址为:http://sourceforge.net/projects/log4cpp/files/latest/download。(log4cpp-1.1.2rc1.tar.gz,仅 577K )



解压后,进入对应的msvc 文件夹(本人使用vs2013,进入了vsvc10,双击msvc10.sln 打开vs,项目列表如下:

直接编译(log4cpp项目,(log4cppLIB编译失败,失败原因:LINK : fatal error LNK1181: 无法打开输入文件“.\Debug\NTEventLogCategories.res”)),暂不处理,再次编译testDll,编译成功后,启动testDLL,显示文件找出不到。(log4cpp\msvc10\log4cpp\Debug\log4cpp.dll 到 log4cpp\msvc10\testDLL\Debug 即可。)



LOG4CPP 在项目中使用

#include <string>
#include "log4cpp/Priority.hh"
#include "log4cpp/Category.hh"
class Log4CppLog
{
public:
Log4CppLog();
Log4CppLog(std::wstring logPath, std::wstring logLevel);
~Log4CppLog();


void SetLogPath(std::wstring logPath, std::wstring logLevel);


bool IsDebugEnable();


void WriteLog(std::wstring logLevel, const std::string& msg);


void WriteLog(std::wstring logLevel, const std::string& fmt, const std::string& arg0);


void WriteLog(std::wstring logLevel, const std::string& fmt, const std::string& arg0, const std::string& arg1);


void WriteLog(std::wstring logLevel, const std::string& fmt, const std::string& arg0, const std::string& arg1, const std::string& arg2);
private:
log4cpp::Priority::PriorityLevel ChangeStringToPriorityLevel(std::wstring level);
void WriteLog4CppLog(log4cpp::Priority::PriorityLevel level, std::string logDate);


private:
std::string strProcessId;
std::wstring strLogPath;
log

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值