Overview
Features
Download
Documentation
Community
Add-Ons & Services

Network logging channel

Please post support and help requests here.

Network logging channel

Postby dbarzo » 19 Jun 2014, 16:06

Hi,

I'm developing a server application and I thought to send the log information also on a socket so I can create a "monitor" application.
Now I wanna ask two question:

1. It make sense? Or there are other "best practices" to do it?
2. Is there yet a "Network Log Channel" around or I have to create it?

Regards,
Daniele.
dbarzo
 
Posts: 38
Joined: 14 Jan 2013, 17:15
Location: Italy

Re: Network logging channel

Postby alex » 19 Jun 2014, 16:33

alex
 
Posts: 1113
Joined: 11 Jul 2006, 16:27
Location: United_States

Re: Network logging channel

Postby alex » 19 Jun 2014, 16:35

There is also Logging/Server in the sandbox but we never quite got around moving it to mainstream.
alex
 
Posts: 1113
Joined: 11 Jul 2006, 16:27
Location: United_States

Re: Network logging channel

Postby dbarzo » 19 Jun 2014, 16:37

Thanks a lot Alex! :)
dbarzo
 
Posts: 38
Joined: 14 Jan 2013, 17:15
Location: Italy

Re: Network logging channel

Postby dbarzo » 18 Jul 2014, 13:16

Since I cannot get it to work, could someone tell me if I'm doing the things right? :)
I would a Logger (MainLogger) writes to 3 channels (Console, File and Syslog) and another, different, Logger (DataLogger) writes to a file...

Code: Select all
      Poco::AutoPtr<FormattingChannel> pFCConsole( new FormattingChannel(new PatternFormatter("%Y-%m-%d %H:%M:%S %t")) );
      pFCConsole->setChannel(new ConsoleChannel);
      pFCConsole->open();

      Poco::AutoPtr<FormattingChannel> pFCFile( new FormattingChannel(new PatternFormatter("%Y-%m-%d %H:%M:%S %N[%P]: %t")) );
      Poco::AutoPtr<FileChannel> rotatedFileChannel( new FileChannel("TBServerlog.log") );

      rotatedFileChannel->setProperty("rotation", "2M");
      rotatedFileChannel->setProperty("archive", "timestamp");
      rotatedFileChannel->setProperty("compress", "true");
      rotatedFileChannel->setProperty("times", "local");

      pFCFile->setChannel(rotatedFileChannel);
      pFCFile->open();

      //Poco::AutoPtr<FormattingChannel> pFCDataLog( new FormattingChannel(new PatternFormatter("%Y-%m-%d %H:%M:%S %N[%P]: %t")) );
      Poco::AutoPtr<FileChannel> pLogFile( new FileChannel("TBServer_data.log") );
      pLogFile->setProperty("rotation", "daily");
      pLogFile->setProperty("archive", "timestamp");
      pLogFile->setProperty("compress", "true");
      pLogFile->setProperty("times", "local");
      pLogFile->open();
      //pFCDataLog->setChannel(pLogFile);
      //pFCDataLog->open();

      std::string syslog_host = pConf->getString("syslog_host", "127.0.0.1");
      Poco::AutoPtr<RemoteSyslogChannel> pRemoteSyslog( new RemoteSyslogChannel(syslog_host, "TBServer") );
      pRemoteSyslog->open();

      Poco::AutoPtr<SplitterChannel > pSplitter( new SplitterChannel() );
      pSplitter->addChannel(pFCConsole);
      pSplitter->addChannel(pFCFile);
      pSplitter->addChannel(pRemoteSyslog);
      pSplitter->open();

      Logger::create("ConsoleLogger", pFCConsole, m_DebugLevel);
      Logger::create("FileLogger", pFCFile, m_DebugLevel);
      Logger::create("RemoteLogger", pRemoteSyslog, m_DebugLevel);
      Logger::create("MainLogger", pSplitter, m_DebugLevel);
      Logger::create("DataLogger", pLogFile, Message::PRIO_TRACE);


Thansk in advance.
dbarzo
 
Posts: 38
Joined: 14 Jan 2013, 17:15
Location: Italy


Return to Support

Who is online

Users browsing this forum: guenter and 2 guests