在提升系统日志水槽后端自动刷新(1.59提振) [英] auto flush in boost syslog sink backend (boost 1.59)
问题描述
有没有刷新()在系统日志后端方法。我面临着提升系统日志下沉的问题,经过6日志消息7日消息没有得到记录到系统日志(缓冲住宿),直到新的日志消息被调用。
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.
我的日志实现:
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->刷新();
syslogSink->flush();
我试着使用flush()方法按<一个href=\"http://www.boost.org/doc/libs/1_59_0/libs/log/doc/html/boost/log/sinks/synchronous_sink.html#idp54313520-bb\" rel=\"nofollow\">http://www.boost.org/doc/libs/1_59_0/libs/log/doc/html/boost/log/sinks/synchronous_sink.html#idp54313520-bb
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.
推荐答案
有是在Boost.Log系统日志后台,因为后台不缓冲没有 auto_flush
方法格式化记录。这个后端与 synchronous_sink
前端一起的刷新
方法基本上是一个无操作并在规定的接口统一所有汇。
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.
由于您使用本机的syslog实现,你可以看看你如何syslog守护进程运行,如果有任何的方式来迫使它刷新其内部缓冲区。这不能从Boost.Log侧进行。
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.
这篇关于在提升系统日志水槽后端自动刷新(1.59提振)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!