#include #include #include #include #include #include #include #include int main(int argc, char *argv[]) { namespace logging = boost::log; namespace sinks = boost::log::sinks; namespace src = boost::log::sources; namespace expr = boost::log::expressions; namespace attrs = boost::log::attributes; namespace keywords = boost::log::keywords; typedef sinks::synchronous_sink sink_t; boost::shared_ptr core = logging::core::get(); // Create a new backend boost::shared_ptr backend(new sinks::syslog_backend( keywords::facility = sinks::syslog::local0, keywords::use_impl = sinks::syslog::udp_socket_based)); // Setup the target address and port to send syslog messages to backend->set_target_address("localhost"); // Create and fill in another level translator for "MyLevel" attribute of type sinks::syslog::custom_severity_mapping 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(backend)); src::severity_logger_mt<> logger; BOOST_LOG(logger) << "Initialized logger"; boost::asio::io_service ioService; boost::asio::ip::udp::socket socket2(ioService); return 0; }