chronoxor / CppLogging

Ultra fast and low latency C++ Logging library with flexible configuration and high throughput in multithreaded environment

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Logs are not added to log file, even log file is not created.

bartalke opened this issue · comments

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 ?

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;
}