我正在尝试使用Boost日志syslog后端为syslog服务器设置syslog客户端。以下是目前我正在尝试使用的示例代码。
void init_builtin_syslog()
{
boost::shared_ptr< logging::core > core = logging::core::get();
// Create a new backend
boost::shared_ptr< sinks::syslog_backend > backend(new sinks::syslog_backend(
keywords::facility = sinks::syslog::local0, 3
keywords::use_impl = sinks::syslog::udp_socket_based 4
));
// Setup the target address and port to send syslog messages to
backend->set_target_address("192.164.1.10", 514); //Instead we need to use TCP TLS based port
// Create and fill in another level translator for "MyLevel" attribute of type string
sinks::syslog::custom_severity_mapping< std::string > mapping("MyLevel");
mapping["debug"] = sinks::syslog::debug;
mapping["normal"] = sinks::syslog::info;
mapping["warning"] = sinks::syslog::warning;
mapping["failure"] = sinks::syslog::critical;
backend->set_severity_mapper(mapping);
// Wrap it into the frontend and register in the core.
core->add_sink(boost::make_shared< sink_t >(backend));
}
那么如何建立这种联系。