Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
bartalke opened this issue May 11, 2020 · 1 comment
Closed

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

bartalke opened this issue May 11, 2020 · 1 comment

Comments

@bartalke
Copy link

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 ?

@chronoxor
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants