Logs are not added to log file, even log file is not created.
bartalke opened this issue · comments
bartalke commented
Hi,
I have the following configuration:
void ConfigureLogger()
{
auto sink = std::make_shared<CppLogging::AsyncWaitFreeProcessor(std::make_shared<CppLogging::BinaryLayout>());
sink->appenders().push_back(std::make_shared<CppLogging::RollingFileAppender>(".", "myfile", "bin.log", 4096, 9, true));
CppLogging::Config::ConfigLogger("example", sink);
}
int main()
{
ConfigureLogger();
CppLogging::Logger logger("example");
auto tmp = 0;
while (tmp != 100)
{
logger.Info("Some message");
++tmp;
}
return 0;
}
I expect that after execution this program, the file "myfile.bin.log" will be created with logs, but there is no such a file. With e.g. FileAppender only empty file is created. Am I doing sth wrong or is it a bug ?
Ivan Shynkarenka commented
Please try the sample below:
void ConfigureLogger()
{
auto sink = std::make_shared<CppLogging::AsyncWaitFreeProcessor>(std::make_shared<CppLogging::BinaryLayout>());
sink->appenders().push_back(std::make_shared<CppLogging::RollingFileAppender>(".", "myfile", "bin.log", 4096, 9, true));
CppLogging::Config::ConfigLogger("example", sink);
CppLogging::Config::Startup();
}
int main()
{
ConfigureLogger();
CppLogging::Logger logger("example");
auto tmp = 0;
while (tmp != 100)
{
logger.Info("Some message");
++tmp;
}
CppLogging::Config::Shutdown();
return 0;
}