You can try to add multiple stream to the backend
:
void init_logging()
{
boost::shared_ptr< logging::core > core = logging::core::get();
// Create a backend and attach a couple of streams to it
boost::shared_ptr< sinks::text_ostream_backend > backend =
boost::make_shared< sinks::text_ostream_backend >();
backend->add_stream(
boost::shared_ptr< std::ostream >(&std::clog, boost::null_deleter()));
backend->add_stream(
boost::shared_ptr< std::ostream >(new std::ofstream("sample.log")));
/*** Add your network stream here ***/
typedef sinks::synchronous_sink< sinks::text_ostream_backend > sink_t;
boost::shared_ptr< sink_t > sink(new sink_t(backend));
core->add_sink(sink);
}
Update
Stick to text_file_backend
, you can use the void set_close_handler(close_handler_type const & handler)
to set a callback function which reads the closed log file and send it to your log server.
If you cannot stand with the delay, then use set_open_handler
, and start a new thread to read the file.
Ultimately, you can subclass text_file_backend
and overload the consume
method which I think the fontend calls. Refer to this page for the backend API