Linux/Unix Syslog writes unwanted characters to log message- using ACE

linux rsyslog ace

146 观看


113 作者的声誉

I am sending log messages to linux syslog in multithreaded environment, using ACE function: ACE_Log_Msg().

In about 5% of the log messages, an unwanted extra characters appear in my syslog output. The code I am using to send log messages to ACE is as follows:

#include "ace/Log_Msg.h"

ACE_Mutex syslog_mtx;
int ACE_TMAIN (int argc, ACE_TCHAR *argv[])
  ACE_Guard<ACE_Mutex> mtx (syslog_mtx);

  ACE_LOG_MSG->open (argv[0], ACE_Log_Msg::SYSLOG, ACE_TEXT ("syslogTest"));

  ACE_DEBUG ((LM_INFO, ACE_TEXT (L"my log message\n")));

  ACE_LOG_MSG->open (argv[0], ACE_Log_Msg::STDERR, ACE_TEXT ("syslogTest"));

  return 0;

And the log messages I see in syslog looks like this:

Oct 9 15:25:20 SYSLOG ~[62266]: my log message
Oct 9 15:25:20 SYSLOG ``[62266]: 6]: my log message

As you can see, extra characters: ~, ``, 6]: seem to be inserted where the application name/process ID appears in syslog format. I can't seem to understand the possible origin of that bug. I will be glad to hear suggestions for the possible cause.

作者: N.avraham 的来源 发布者: 2017 年 12 月 27 日

回应 (1)


2638 作者的声誉

Remove the L before "my log message", ACE_TEXT already handles that

作者: Johnny Willemsen 发布者: 28.12.2017 09:10