#define BOOST_LOG_DYN_LINK #define BOOST_LOG_USE_NATIVE_SYSLOG #include #include #include #include #include #include // Complete sink type typedef boost::log::sinks::synchronous_sink< boost::log::sinks::syslog_backend > sink_t; namespace logging = boost::log; namespace sinks = boost::log::sinks; namespace keywords = boost::log::keywords; namespace sources = boost::log::sources; void init_native_syslog() { boost::shared_ptr< logging::core > core = logging::core::get(); // Create a backend boost::shared_ptr< sinks::syslog_backend > backend(new sinks::syslog_backend( keywords::facility = sinks::syslog::user, keywords::use_impl = sinks::syslog::native )); // Set the straightforward level translator for the "Severity" attribute of type int backend->set_severity_mapper(sinks::syslog::direct_severity_mapping< int >("Severity")); // Wrap it into the frontend and register in the core. // The backend requires synchronization in the frontend. core->add_sink(boost::make_shared< sink_t >(backend)); } int main(int argc, char** argv) { init_native_syslog(); sources::logger logger; BOOST_LOG(logger) << "TEST_SYSLOG"; return 0; }