2


  I have using boost log for past three months. I am using boost logger as static in inside the class.

BoostLogger.h:

class CBoostLogger
{
private: 
  SharedPtr< SinkFileBackend > backend; 
  ...
public: 
  static src::wseverity_logger_mt< logging::trivial::severity_level > slg;
...
}

BoostLogger.cpp:

#include "BoostLogger.h"
////////////////////////////////////
//Global Declarations
////////////////////////////////////
src::wseverity_logger_mt< logging::trivial::severity_level > CBoostLogger::slg;


  But I want to create individual logger for individual class object.

  Is it possible to create?

  Give your suggestions?

Regards,
   Arun

1 Answers1

1

Several sources say that Boost logger can have multiple instances. You can read about this at this link or this link.

IMO I would use a single logger object and use specific messages to tell me from where the log entry originated, formated as follows: (file), (line of code), (method) log message;

E.g.: Main.cpp 25 main() : Warning, unable to open file.

Ionut V.
  • 110
  • 7
  • Thanks. Assume that I am going to create I am having a class. In class, I create source::logger lg; as public. And in class constructor, I am creating file using add_file_log. Is it possible to write in individual files using different class objects. – Arun kumar Kalaiarasan Jun 28 '16 at 13:30
  • I used to write a single log file, then if really necessary I would parse the log file to extract the information I need, or I would use the search options from Notepad++ to filter out the results. – Ionut V. Jun 28 '16 at 14:36