abumq / easyloggingpp

C++ logging library. It is extremely powerful, 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.75k stars 918 forks source link

[Question] How exactly load several loggers from the one config? #838

Closed yalov closed 1 year ago

yalov commented 1 year ago

In the readme, in one section you have an example of the config, and in the next one, how to load logger configuration, but how to load several configuration from one config into several loggers?

example of my.conf:

* GLOBAL:
   FORMAT               =  "%datetime{%Y-%M-%d %H:%m:%s.%g}      %level: %msg"
   FILENAME             =  "log.txt"
   ENABLED              =  true
   TO_FILE              =  true
   TO_STANDARD_OUTPUT   =  true
   SUBSECOND_PRECISION  =  3
   PERFORMANCE_TRACKING =  true
   MAX_LOG_FILE_SIZE    =  268435456 ## 256MB
   LOG_FLUSH_THRESHOLD  =  100 
* OUTPUT:
   FORMAT               =  "%datetime{%Y.%M.%d %H:%m:%s.%g} %msg"
   FILENAME             =  "output.txt"

main.cpp (doesn't work):

#include "easylogging++.h"
INITIALIZE_EASYLOGGINGPP
int main() {
    START_EASYLOGGINGPP(argc, argv);
    el::Configurations conf("my.conf");
    el::Loggers::reconfigureAllLoggers(conf);
}

And how to use several loggers (ex. GLOBAL and OUTPUT from the config) alternately? other.cpp

#include "easylogging++.h"

LOG1(INFO) << "message for my.log";
LOG2(INFO) << "message for output.log";
yalov commented 1 year ago

https://github.com/abumq/easyloggingpp/issues/422