c++ - 更改 Google glog 中的日志记录目录

标签 c++ logging glog

如何更改 Google glog 中的输出目录?

我只找到了 google::SetLogDestination(google::LogSeverity, const char* path)

尝试过:

google::SetLogDestination(ERROR, "C:\\log\\error.log);
google::InitGoogleLogging("Test");  

LOG(ERROR) << "TEST";

但什么都没写!

顺便说一句:如果您建议另一个轻量级、易于使用且线程安全的库,请告诉我!

感谢您的帮助!

最佳答案

您还可以执行以下操作之一:

只要安装了 GFlgas 库,就将日志目录作为命令行参数传递:

./your_application --log_dir=/some/log/directory

如果您不想在命令行中传递它而是在源代码中设置它:

FLAGS_log_dir = "/some/log/directory";

如果未安装 Google gflags 库,您可以将其设置为环境变量:

GLOG_log_dir=/some/log/directory ./your_application

关于c++ - 更改 Google glog 中的日志记录目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19291499/

相关文章:

go - elogrus 未找到事件连接

react-native - Mojave + Xcode 10构建在glog config.h,gflags/gflags.h上失败

linux - undefined symbol 引用 '_ULx86_64_step' libunwind.so.8 : error adding symbols: DSO missing from command line

c++ - 如何使 QLineEdit 在 Windows 中不可编辑

c++ - 重载C++运算符以将对象中的指针设置为其他对象

C++ 生成警告 : dereferencing type-punned pointer will break strict-aliasing rules

python - 如何配置日志处理程序以生成每周轮换的日志文件?

python - 在 django 项目中生成此日志文件结构所需的建议

c++ - 为什么 cmake 选错了库?

c++ - 检测文件是否在 C++ 中打开