下载源码,使用cmake编译,最后得到了32位的静态库 glog.lib
使用库时要注意添加以下预定义:
GLOG_NO_ABBREVIATED_SEVERITIES;
GOOGLE_GLOG_DLL_DECL=;
然后就可以简单的实现
#include "stdafx.h"
#ifndef GOOGLE_GLOG_DLL_DECL #define GOOGLE_GLOG_DLL_DECL #endif #ifndef GLOG_NO_ABBREVIATED_SEVERITIES #define GLOG_NO_ABBREVIATED_SEVERITIES #endif
#include <glog/logging.h> int _tmain(int argc, _TCHAR* argv[]) { //glog初始化 google::InitGoogleLogging("gLog");
//设置日志的路径 FLAGS_log_dir = "D:\ABC";
LOG(INFO) << "INFO"; LOG(INFO) << "INFO1";
LOG(WARNING) << "WARNING"; LOG(WARNING) << "WARNING1";
LOG(ERROR) << "ERROR"; LOG(ERROR) << "ERROR1";
//关闭 google::ShutdownGoogleLogging(); return 0; }