Overview
Features
Download
Documentation
Community
Add-Ons & Services

can Poco logfile with the file line number??

A general discussion forum.

can Poco logfile with the file line number??

Postby zhugw519 » 27 Sep 2012, 10:09

I write a program,and the format like this:

Code: Select all
//1、create file channel
   Poco::AutoPtr<Poco::FileChannel> fileChannel(new Poco::FileChannel);
   fileChannel->setProperty("path", "OSIP.log");
   fileChannel->setProperty("rotation", "1024K");
   fileChannel->setProperty("compress", "true");

   //2、create pattern format
   Poco::AutoPtr<Poco::PatternFormatter> patternFormatter(new Poco::PatternFormatter);
   patternFormatter->setProperty("times", "local");
   patternFormatter->setProperty("pattern", "[%Y-%m-%d %H:%M:%S.%i %s:%u %p]-%t");

   //3、create format channel
   AutoPtr<FormattingChannel> formatChannel(new FormattingChannel(patternFormatter, fileChannel));
   logger.setChannel(formatChannel);


I use the log like this:
Code: Select all
logger.information("Admin thread running......");


and the log file print like this:
[2012-09-27 15:51:42.202 Admin.cpp:0 Information]-Admin thread running......

I use the "%u" want to print the line number,but it not effect,can anyone help me???
zhugw519
 
Posts: 2
Joined: 27 Sep 2012, 10:03

Re: can Poco logfile with the file line number??

Postby pjwhite » 29 Sep 2012, 14:55

I think if you use the macros provided at the bottom of Logger.h:

poco_fatal() automatically sets the __FILE__ and __LINE__ variables into the message, which you can then print using the pattern formatter.
pjwhite
 
Posts: 11
Joined: 30 Aug 2012, 04:45

Re: can Poco logfile with the file line number??

Postby zhugw519 » 17 Oct 2012, 09:08

pjwhite wrote:I think if you use the macros provided at the bottom of Logger.h:

poco_fatal() automatically sets the __FILE__ and __LINE__ variables into the message, which you can then print using the pattern formatter.


hi,guy, thanks, It works as you what say. :D
zhugw519
 
Posts: 2
Joined: 27 Sep 2012, 10:03


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 2 guests