1、下载plog第三方库,解压后放到D盘根目录

2、VS项目属性中引入

plog日志库(c++)

 3、使用方法

#include <plog/Log.h> //先引入第三方
#include <iostream> //后引入标准库

int getUserInput()
{
    LOGD << "getUserInput() called"; // 输出到日志的内容

    std::cout << "Enter a number: ";
    int x{};
    std::cin >> x;
    return x;
}

int main()
{
    plog::init(plog::debug, "Logfile.txt"); // 启动日志
    //plog::init(plog::none, "Logfile.txt"); // 关闭日志,LOGD << 不会再写入任何内容
    LOGD << "main() called"; // 输出到日志的内容

    int x{ getUserInput() };
    std::cout << "You entered: " << x;

    return 0;
}

在项目路径中生成Logfile.txt

plog日志库(c++)

相关文章:

  • 2021-06-06
  • 2022-12-23
  • 2021-09-04
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-06
猜你喜欢
  • 2022-12-23
  • 2022-01-07
  • 2021-11-02
相关资源
相似解决方案