Overview
Features
Download
Documentation
Community
Add-Ons & Services

Logging local time

Please post support and help requests here.

Logging local time

Postby gandriotakis » 18 Oct 2012, 23:03

How do I configure a FileChannel to use local time? I tried setting "times" to "local" but it seemed to have no effect.
gandriotakis
 
Posts: 29
Joined: 02 Dec 2011, 20:45

Re: Logging local time

Postby alex » 18 Oct 2012, 23:32

gandriotakis wrote:I tried setting "times" to "local" but it seemed to have no effect.

It should. Hard to tell without seeing the code.
alex
 
Posts: 1047
Joined: 11 Jul 2006, 16:27
Location: United_States

Re: Logging local time

Postby gandriotakis » 19 Oct 2012, 14:36

AutoPtr<Poco::Channel> pChannel (new Poco::FileChannel(logFile));
pChannel->setProperty(Poco::FileChannel::PROP_TIMES, "local");
gandriotakis
 
Posts: 29
Joined: 02 Dec 2011, 20:45

Re: Logging local time

Postby alex » 19 Oct 2012, 16:30

Well, that does not tell very much. Are there any formatters used?
alex
 
Posts: 1047
Joined: 11 Jul 2006, 16:27
Location: United_States

Re: Logging local time

Postby gandriotakis » 19 Oct 2012, 17:16

Sorry, here is a more complete snippet.

// create a FileChannel with time tagged log records
AutoPtr<Poco::Channel> pChannel (new Poco::FileChannel(logFile));
pChannel->setProperty(Poco::FileChannel::PROP_TIMES, "local");

AutoPtr<Poco::Formatter> formatter(new Poco::PatternFormatter("%h:%M:%S.%i- %t"));
AutoPtr<Poco::Channel> formattingChannel(new Poco::FormattingChannel(formatter, pChannel));
formattingChannel->setProperty(Poco::FileChannel::PROP_TIMES, "local");

m_logger.setChannel(formattingChannel);
gandriotakis
 
Posts: 29
Joined: 02 Dec 2011, 20:45

Re: Logging local time

Postby alex » 19 Oct 2012, 19:54

You are setting property on the FormattingChannel which is just duplicating (already set) setting for the FileChannel. You should instead set it on the formatter.
Try this:
Code: Select all
AutoPtr<Poco::Channel> pChannel (new Poco::FileChannel(logFile));
pChannel->setProperty(Poco::FileChannel::PROP_TIMES, "local");

AutoPtr<Poco::Formatter> formatter(new Poco::PatternFormatter("%h:%M:%S.%i- %t"));
formatter->setProperty(Poco::FileChannel::PROP_TIMES, "local");
AutoPtr<Poco::Channel> formattingChannel(new Poco::FormattingChannel(formatter, pChannel));

m_logger.setChannel(formattingChannel);
alex
 
Posts: 1047
Joined: 11 Jul 2006, 16:27
Location: United_States

Re: Logging local time

Postby gandriotakis » 19 Oct 2012, 22:26

That was actually just the last of several attempts. I tried setting it only on the channel and only on the formatter also but got the same result (times are UTC)
gandriotakis
 
Posts: 29
Joined: 02 Dec 2011, 20:45

Re: Logging local time

Postby alex » 19 Oct 2012, 22:39

Works for me. I actually ran the code I posted here.
EDIT (sample output):
Code: Select all
C:\trunk\Foundation\samples\Logger\bin>type c:\temp\log
The system cannot find the file specified.
C:\trunk\Foundation\samples\Logger\bin>date
The current date is: Fri 10/19/2012
C:\trunk\Foundation\samples\Logger\bin>time
The current time is: 15:44:07.44
C:\trunk\Foundation\samples\Logger\bin>.\Loggerd.exe
C:\trunk\Foundation\samples\Logger\bin>type C:\temp\test.log
03:44:11.385- test
alex
 
Posts: 1047
Joined: 11 Jul 2006, 16:27
Location: United_States

Re: Logging local time

Postby gandriotakis » 19 Oct 2012, 23:05

Thank you. As you indicated I was not differentiating between the formatter and the channel. I don;t have all the bits and pieces clear in my head yet.
gandriotakis
 
Posts: 29
Joined: 02 Dec 2011, 20:45


Return to Support

Who is online

Users browsing this forum: No registered users and 2 guests

cron