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

How to make path of log file in the config relative to exe folder, but not the active folder? #847

Open
yalov opened this issue Nov 9, 2023 · 0 comments

Comments

@yalov
Copy link

yalov commented Nov 9, 2023

I can get the abs_path of the folder of exe in the code, and prepend it to the log path in global config:

    el::Loggers::configureFromGlobal((get_folder_of_exe() / "easylogging++.conf").string().c_str());
    
    // update path of the main log file to be not relative to active folder, but to the folder of exe
    auto logger = el::Loggers::getLogger("default");
    std::string abs_filepath = (get_folder_of_exe() / logger->typedConfigurations()->filename(el::Level::Info)).string();
    
    logger->configurations()->setGlobally(el::ConfigurationType::Filename, abs_filepath);
    logger->reconfigure();

but:

  • it still create empty log file in the old location,
  • it requires hardcode of logger id ("default"), but I want path to be related to the exe of all loggers, that could be added in the global.conf later.

P.S. "active folder" is different from the "exe folder" if I try to launch exe in the console from a different location.

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

1 participant