abumq / easyloggingpp

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.8k stars 929 forks source link

easylogging conf file is picked up, but level disabling ignored when using hierarchical levels #600

Open bwagner opened 6 years ago

bwagner commented 6 years ago

The cpp source:

#include "easylogging++.h"

INITIALIZE_EASYLOGGINGPP

int main(int argv, char* argc[]) {
  el::Configurations conf("easylogging.conf");
  el::Loggers::reconfigureAllLoggers(conf);
  el::Loggers::addFlag(el::LoggingFlag::HierarchicalLogging);
  LOG(TRACE) << "My first TRACE log using default logger with conf file";
  LOG(DEBUG) << "My first DEBUG log using default logger with conf file";
//  LOG(FATAL) << "My first FATAL log using default logger with conf file"; // terminates app
  LOG(ERROR) << "My first ERROR log using default logger with conf file";
  LOG(WARNING) << "My first WARNING log using default logger with conf file";
  LOG(INFO) << "My first INFO log using default logger with conf file";
  return 0;
}

the easylogging.conf:

* GLOBAL:
   FORMAT               =  "%datetime %msg"
   FILENAME             =  "easylogging.log"
   ENABLED              =  false
   TO_FILE              =  true
   TO_STANDARD_OUTPUT   =  true
   SUBSECOND_PRECISION  =  6
   PERFORMANCE_TRACKING =  true
   MAX_LOG_FILE_SIZE    =  2097152 ## 2MB - Comment starts with two hashes (##)
   LOG_FLUSH_THRESHOLD  =  100 ## Flush after every 100 logs
* TRACE:
   ENABLED              = false
   FORMAT               = "%datetime{%d/%M} %func %msg"
* DEBUG:
   ENABLED              = false
* ERROR:
   ENABLED              = false
* WARNING:
   ENABLED              = false
* INFO:
   ENABLED              = false

the output I get:

07/01 int main(int, char **) My first TRACE log using default logger with conf file
2018-01-07 15:31:54,926377 My first DEBUG log using default logger with conf file
2018-01-07 15:31:54,926391 My first ERROR log using default logger with conf file
2018-01-07 15:31:54,926403 My first WARNING log using default logger with conf file
2018-01-07 15:31:54,926413 My first INFO log using default logger with conf file

I've renamed the easylogging.conf and got an error that it wasn't picked up, so easylogging reads my conf file. Also, TRACE is formatted differently as specified in the conf-file.

But all output is generated even though all ENABLED configuration values are false. When I remove the statement setting the hierarchical logging flag, things seem to work. I wonder how to properly work with the hierarchical setting. In my understanding, enabling TRACE would enable all other levels, while setting a more severe level would only enable that and the more severe levels. Thank you

SombreLoup commented 5 years ago

I have the same problem. Probably just a misunderstanding of the documentation. Anyway, I don't know what I have to do... Someone for lighting me ? A link ? A sample ? Thanks