Is there any method to flush() in syslog backend. I am facing issue with boost syslog sink, after 6 log messages the 7th message is not getting logged into syslog (stays in buffer) until new log message is called.
My syslog implementation:
typedef sinks::synchronous_sink< sinks::syslog_backend > sink_t;
boost::shared_ptr< sink_t > syslogSink(
new sink_t(
keywords::facility = sinks::syslog::local0,
keywords::use_impl = sinks::syslog::native
));
sinks::syslog::custom_severity_mapping< std::string > mapping("severityLevel");
mapping["debug"] = sinks::syslog::debug;
mapping["info"] = sinks::syslog::info;
mapping["notice"] = sinks::syslog::info;
mapping["warning"] = sinks::syslog::warning;
mapping["error"] = sinks::syslog::error;
mapping["critical"] = sinks::syslog::critical;
syslogSink->locked_backend()->set_severity_mapper(mapping);
syslogSink->locked_backend()->auto_flush(m_logAutoFlush);
logging::formatter formatter = CEFFormat();
syslogSink->set_formatter(formatter);
syslogSink->set_filter(expr::attr<std::string>("Channel") == "signatureID");
logging::core::get()->add_sink(syslogSink);
syslogSink->flush();
I tried using flush() method as per http://www.boost.org/doc/libs/1_59_0/libs/log/doc/html/boost/log/sinks/synchronous_sink.html#idp54313520-bb
but it didn't help and still log messages are not logged in time by staying in buffer.
There is no auto_flush
method for the syslog backend in Boost.Log because the backend doesn't buffer formatted records. The flush
method for this backend in conjunction with the synchronous_sink
frontend is basically a no-op and provided for interface unification across all sinks.
Since you're using the native syslog implementation, you should have a look at how your syslog daemon operates and if there is any way to force it flush its internal buffers. This cannot be done from Boost.Log side.