Overview
Features
Download
Documentation
Community
Add-Ons & Services

Message Source for Logger

A general discussion forum.

Message Source for Logger

Postby asiflse2 » 10 Aug 2011, 19:34

Hi,

No matter what I do, it seems that Poco will never get the Source that I provide it to the Windows Event Viewer. Below is the code I am using but Poco forcefully changes the source to the name of Program executable instead of the source that I supplied (MyClassSource):
********************************************************************************************************************************************************
class MyClass {
public:
MyClass() :
channel_(Poco::LoggingFactory::defaultFactory().createChannel("EventLogChannel")),
logger_(Poco::Logger::create("MyClassSource",channel_,Poco::Message::PRIO_TRACE))
{
Poco::Message m("MyClassSource"," starting up fresh now :)", Poco::Message::PRIO_TRACE);
std::cout << std:: endl << "Message Source is: " << m.getSource() << std::endl;
m.setSource("CT01");
logger_.log(m);
}


Poco::Channel *channel_;
Poco::Logger logger_;

};

********************************************************************************************************************************************************

I need to fix this urgently and would be thankful if you could help me work around this bug.

Best, Asif
PS: I am not using Poco::Application. I am just using Poco's Logging framework.
asiflse2
 
Posts: 7
Joined: 10 Aug 2011, 19:17

Re: Message Source for Logger

Postby guenter » 12 Aug 2011, 07:14

To change the name of the event source in the EventLogChannel, use Channel::setProperty:

Code: Select all
channel_.setProperty("name", "CT01");


This has nothing to do with the source from the log message.
guenter
 
Posts: 1135
Joined: 11 Jul 2006, 16:27
Location: Austria

Re: Message Source for Logger

Postby asiflse2 » 12 Aug 2011, 08:17

Thanks, the problem is solved now. But what Poco presentation PDF says amounts to something like this: setting name of the logger is important because it sets the name of the event source. I did only that. I haven't looked into properties though. Will do now when I get time.

Thanks again,Asif
asiflse2
 
Posts: 7
Joined: 10 Aug 2011, 19:17


Return to General Discussion

Who is online

Users browsing this forum: alex and 1 guest