[Boost-bugs] [Boost C++ Libraries] #12364: In boost::log, how to re-connect to a remote server (like logstash)?

Subject: [Boost-bugs] [Boost C++ Libraries] #12364: In boost::log, how to re-connect to a remote server (like logstash)?
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2016-07-29 21:28:57


#12364: In boost::log, how to re-connect to a remote server (like logstash)?
------------------------------+---------------------
 Reporter: xinyan.zhang@… | Owner: andysem
     Type: Support Requests | Status: new
Milestone: To Be Determined | Component: log
  Version: Boost 1.61.0 | Severity: Problem
 Keywords: |
------------------------------+---------------------
 By using boost::asio::ip::tcp::iostream and boost::log, I am trying to
 send log records to a remote server like logstash. But I need to handle
 the network disconnection/reconnection. Unfortunately, I did not find any
 way for tcp::iostream.

     Is it possible to get a notification or exception when the tcp
 connection is broken?
     Can I use ip::tcp::socket instead of tcp::iostream in boost::log?
 Thank you.

 My code looks like:

 {{{
 typedef boost::log::sinks::asynchronous_sink<
 boost::log::sinks::text_ostream_backend > tcp_sink;
 boost::shared_ptr< tcp_sink > networkSink;

 // init tcp stream
 boost::shared_ptr< sinks::text_ostream_backend > backend =
     boost::make_shared< sinks::text_ostream_backend >();

 boost::shared_ptr< boost::asio::ip::tcp::iostream > stream =
 boost::make_shared< boost::asio::ip::tcp::iostream >();
 stream->connect("logstash", "1111");


 backend->add_stream(stream);

 networkSink = boost::make_shared< tcp_sink >();
 networkSink->set_formatter(fmt);
 networkSink->set_filter(severity <= severityThreshold);
 networkSink = boost::make_shared<tcp_sink>(backend );
 logging::core::get()->add_sink(networkSink);


 }}}

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/12364>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:20 UTC