Modify

#12600 closed Bugs (fixed)

Syslog broken in 1.62.0

Reported by: mario.m.kaip@… Owned by: Andrey Semashev
Milestone: To Be Determined Component: log
Version: Boost 1.62.0 Severity: Showstopper
Keywords: Cc:

Description

Hello,

syslog seems to be broken in 1.62.0.

I tried to use native and UDP based syslog to localhost which was fine in 1.61.0. In 1.62.0 no exceptions are thrown no log message arrives syslog.

Can anybody confirm this behaviour?

Operating system: RedHat? 7.1 Boost compiled using GCC 4.8.3-9 with BOOST_LOG_DYN_LINK

Thanks

Attachments (3)

main.cpp (1.4 KB) - added by mario.m.kaip@… 13 months ago.
Minimal example for syslog
strace_1.61.0.log (41.8 KB) - added by mario.m.kaip@… 13 months ago.
strace of example using boost 1.61.0
strace_1.62.0.log (42.6 KB) - added by mario.m.kaip@… 13 months ago.
strace of example using boost 1.62.0

Download all attachments as: .zip

Change History (9)

comment:1 Changed 13 months ago by Andrey Semashev

You'll have to do some debugging in order to have suggestions. First, run your code under strace and see if the messages are being sent to the syslog service. If not, verify that your filters don't discard log records. If they don't, please attach a minimal compilable code sample that reproduces the problem.

Changed 13 months ago by mario.m.kaip@…

Attachment: main.cpp added

Minimal example for syslog

Changed 13 months ago by mario.m.kaip@…

Attachment: strace_1.61.0.log added

strace of example using boost 1.61.0

Changed 13 months ago by mario.m.kaip@…

Attachment: strace_1.62.0.log added

strace of example using boost 1.62.0

comment:2 Changed 13 months ago by anonymous

I created a minimal example for syslog using code from http://www.boost.org/doc/libs/1_62_0/libs/log/doc/html/log/detailed/sink_backends.html

Minimal example:

#define BOOST_LOG_DYN_LINK
#define BOOST_LOG_USE_NATIVE_SYSLOG

#include <boost/log/core.hpp>
#include <boost/log/sources/logger.hpp>

#include <boost/smart_ptr/shared_ptr.hpp>
#include <boost/log/common.hpp>
#include <boost/log/sinks/sync_frontend.hpp>
#include <boost/log/sinks/syslog_backend.hpp>

// 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;
}

Compiled with Intel compiler:

icpc -m64 -c -g -Ideps/include -std=c++11 -MMD -MP -MF "main.o.d" -o main.o main.cpp

icpc -m64 -o syslog-testprogram main.o -Ldeps/libs -Wl,-rpath,'deps/libs' -lboost_log -lboost_log_setup -lboost_system -lboost_thread

Boost is located in ./deps relative to main.cpp. The strace produced with boost 1.61.0 and 1.62.0 is attached. I can't see useful information there.

comment:3 Changed 13 months ago by mario.m.kaip@…

Also tested with GCC 4.8.3. Same result, no syslog with Boost 1.62.0.

comment:4 Changed 13 months ago by Andrey Semashev

As you can see in the strace output, the process does send your message (see the last sendmsg call with string "<14> Nov 10 15:10:56 WS14 TEST_"...). The message format is slightly different from the other log, but that's fixed in 1.63 (see https://github.com/boostorg/log/commit/084f848d1461f16c0a6871694076aa36995d4f80 and https://github.com/boostorg/log/commit/d595b6de33c85ec3bf7c81fc2eb5c4537bdfd786).

The strace log also indicates that UDP socket-based backend is used even when you specify native. This can happen if support for native syslog was not compiled in (i.e. BOOST_LOG_USE_NATIVE_SYSLOG was not defined when Boost was built). I think, this could have changed in 1.62, and needs to be fixed. If that's the case, and your syslog daemon is not configured to listen for UDP packets, then the messages are lost. You can try rebuilding Boost and your code with BOOST_LOG_USE_NATIVE_SYSLOG defined and see if that helps.

comment:5 Changed 13 months ago by mario.m.kaip@…

Thank you for this helpful comment. I builded Boost 1.62.0 with BOOST_LOG_USE_NATIVE_SYSLOG and everythink works fine.

Is this only a workaround for 1.62.0 or is this the intended usage in future boost releases?

comment:6 Changed 13 months ago by Andrey Semashev

Resolution: fixed
Status: newclosed

I've re-implemented native syslog detection in https://github.com/boostorg/log/commit/299603ff024c6eaf73d9f52818faab7e7ac81ba0. If everything goes fine, it'll be released in 1.63 and you won't have to define the macro yourself.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Andrey Semashev.
The resolution will be deleted.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.