C++ logging library. It is powerful, supports asynchronous low latency, extendable, light-weight, fast performing, thread and type safe and consists of many built-in features. It provides ability to write logs in your own customized format. It also provide support for logging your classes, third-party libraries, STL and third-party containers etc.
MIT License
3.78k
stars
924
forks
source link
How to make path of log file in the config relative to exe folder, but not the active folder? #847
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.
I can get the abs_path of the folder of exe in the code, and prepend it to the log path in global config:
but:
P.S. "active folder" is different from the "exe folder" if I try to launch exe in the console from a different location.