【发布时间】:2018-06-19 02:08:47
【问题描述】:
我正在使用 spdlog 库进行 C++ 日志记录。我有一个同时具有stdout 和rotating_file_sink_mt sincs 的记录器:
auto std_out_sinc = std::make_shared<spdlog::sinks::stdout_sink_mt>();
auto file_sinc = std::make_shared<spdlog::sinks::rotating_file_sink_mt>("1.log");
sinks.push_back(std_out_sinc);
sinks.push_back(file_sync);
auto combined_logger = std::make_shared<spdlog::logger>("root", begin(sinks), end(sinks));
我想为不同的 sincs 提供不同的日志格式。例如,标准输出的非常简单的格式(默认)和基于文件的 sinc 的 json 格式(由日志索引服务解析)。这在 spdlog 中可行吗?
【问题讨论】: