Thread: [Cppcms-users] question about booster::log
Brought to you by:
artyom-beilis
From: chenshu <csf...@gm...> - 2011-10-13 06:29:46
|
Hello, I tried booster::log today.If I added sink explicitly below,it worked fine,and I could see the log info in log file. void init_log(){ booster::shared_ptr<booster::log::sinks::file> f(new booster::log::sinks::file()); f->open("my_log"); booster::log::logger::instance().add_sink(f); } int main(int argc,char ** argv){ try { init_log(); BOOSTER_ERROR("module") << "Message " << 3.14159; .... } 2011-10-13 06:18:44 GMT; module, error: Message 3.14159 (main.cpp:72) But if I configured it in config.js like so,I couldn't see any log info,only log file was created. "logging":{ "level":"debug", "file":{ "name":"km_log", "append":false, "max_files":100 } } I looked into your codes and found some code here: std::string log_file; if(!(log_file=settings().get("logging.file.name","")).empty()) { booster::shared_ptr<sinks::file> file(new sinks::file()); int max_files=0; if((max_files = settings().get("logging.file.max_files",0)) > 0) file->max_files(max_files); bool append = false; if((append = settings().get("logging.file.append",false))==true) file->append(); file->open(log_file); logger::instance().add_sink(file); } It looked the same as mine code.So no idea now. |
From: Artyom B. <art...@ya...> - 2011-10-16 18:32:20
|
> I tried booster::log today.If I added > sink explicitly below,it worked > fine,and I could see the log info in log file. > > void init_log(){ > booster::shared_ptr<booster::log::sinks::file> > f(new > booster::log::sinks::file()); > f->open("my_log"); > booster::log::logger::instance().add_sink(f); > } > > int main(int argc,char ** argv){ > > try { > init_log(); > BOOSTER_ERROR("module") << > "Message " << 3.14159; > .... > } > > 2011-10-13 06:18:44 GMT; module, error: Message 3.14159 > (main.cpp:72) > > > But if I configured it in config.js like > so,I couldn't see any log > info,only log file was created. > > "logging":{ > "level":"debug", > "file":{ > "name":"km_log", > "append":false, > "max_files":100 > } > } > > I looked into your codes and found some code here: > std::string log_file; > > if(!(log_file=settings().get("logging.file.name","")).empty()) > { > > booster::shared_ptr<sinks::file> > file(new sinks::file()); > int max_files=0; > if((max_files = > settings().get("logging.file.max_files",0)) > 0) > > file->max_files(max_files); > bool append = > false; > if((append = > settings().get("logging.file.append",false))==true) > > file->append(); > > file->open(log_file); > > logger::instance().add_sink(file); > } > > It looked the same as mine code.So no idea now. > Where do you log the data? Can you be more specific? Are you sure you get to the log part? Do you see log file created? files rotated? Small (full) sample would help me to figure out what is the problem. Artyom |
From: 陈抒 <csf...@gm...> - 2011-11-02 03:11:30
|
I figured out the real reason.There is no log info because my code try to produce the log info before running cppcms::service object. My configuration is correct. After calling cppcms::service.run method,I can see my log now. Another question, we are in GMT+8(Beijing),but the time zone in log file is GMT 0 , so how can I config it to another time zone? 陈抒 Best regards http://blog.csdn.net/sheismylife On Mon, Oct 17, 2011 at 2:32 AM, Artyom Beilis <art...@ya...> wrote: > > > I tried booster::log today.If I added > > sink explicitly below,it worked > > fine,and I could see the log info in log file. > > > > void init_log(){ > > booster::shared_ptr<booster::log::sinks::file> > > f(new > > booster::log::sinks::file()); > > f->open("my_log"); > > booster::log::logger::instance().add_sink(f); > > } > > > > int main(int argc,char ** argv){ > > > > try { > > init_log(); > > BOOSTER_ERROR("module") << > > "Message " << 3.14159; > > .... > > } > > > > 2011-10-13 06:18:44 GMT; module, error: Message 3.14159 > > (main.cpp:72) > > > > > > But if I configured it in config.js like > > so,I couldn't see any log > > info,only log file was created. > > > > "logging":{ > > "level":"debug", > > "file":{ > > "name":"km_log", > > "append":false, > > "max_files":100 > > } > > } > > > > I looked into your codes and found some code here: > > std::string log_file; > > > > if(!(log_file=settings().get("logging.file.name","")).empty()) > > { > > > > booster::shared_ptr<sinks::file> > > file(new sinks::file()); > > int max_files=0; > > if((max_files = > > settings().get("logging.file.max_files",0)) > 0) > > > > file->max_files(max_files); > > bool append = > > false; > > if((append = > > settings().get("logging.file.append",false))==true) > > > > file->append(); > > > > file->open(log_file); > > > > logger::instance().add_sink(file); > > } > > > > It looked the same as mine code.So no idea now. > > > > Where do you log the data? > Can you be more specific? Are you sure you get > to the log part? Do you see log file created? > files rotated? > > Small (full) sample would help me to figure out > what is the problem. > > Artyom > > > > ------------------------------------------------------------------------------ > All the data continuously generated in your IT infrastructure contains a > definitive record of customers, application performance, security > threats, fraudulent activity and more. Splunk takes this data and makes > sense of it. Business sense. IT sense. Common sense. > http://p.sf.net/sfu/splunk-d2d-oct > _______________________________________________ > Cppcms-users mailing list > Cpp...@li... > https://lists.sourceforge.net/lists/listinfo/cppcms-users > |
From: Artyom B. <art...@ya...> - 2011-11-02 09:29:03
|
> Another question, we are in GMT+8(Beijing),but the time zone in log file is GMT 0 , > so how can I config it to another time zone? Currently GMT is hard coded. Actually it should be not hard to make it configurable. and it would be very good to add this to logging system. Open a feature request in bug tracking system so I will not forget. Meanwhile you can only implement your own sink... Artyom |
From: 陈抒 <csf...@gm...> - 2011-11-02 11:17:00
|
OK.I added a new feature. 陈抒 Best regards http://blog.csdn.net/sheismylife On Wed, Nov 2, 2011 at 5:28 PM, Artyom Beilis <art...@ya...> wrote: > > > > Another question, we are in GMT+8(Beijing),but the time zone in log > file is GMT 0 , > > so how can I config it to another time zone? > > Currently GMT is hard coded. > Actually it should be not hard to make it configurable. > and it would be very good to add this to logging system. > > > Open a feature request in bug tracking system so I will not forget. > > Meanwhile you can only implement your own sink... > > Artyom > > > > ------------------------------------------------------------------------------ > RSA® Conference 2012 > Save $700 by Nov 18 > Register now! > http://p.sf.net/sfu/rsa-sfdev2dev1 > _______________________________________________ > Cppcms-users mailing list > Cpp...@li... > https://lists.sourceforge.net/lists/listinfo/cppcms-users > |