How to log same message with syslog()?
<p>I'm trying to use <code>syslog.h</code> libraries to log message in my projects. I noticed that if I try to log the same message, in <code>/var/log/syslog</code> it appears only one time; here is my example code and setting:</p>

<pre><code>int main(int argc, char *argv[])
{
  //Initialize syslog
  setlogmask(LOG_UPTO(LOG_NOTICE));
  openlog("example_process", LOG_CONS | LOG_PID | LOG_NDELAY, LOG_USER);

  while(main_loop == LOOP_CONTINUE)
    {
       syslog(LOG_ERR, "Data Logged!\n");
       sleep(60);
    }

  closelog();
}
</code></pre>

<p>and this is the result:</p>

<pre><code>Feb 11 23:27:19 andrea-Aspire-5745G example_process[17332]: Data Logged!
andrea@andrea-Aspire-5745G:~$ 
</code></pre>

<p>But if I change the code in</p>

<pre><code>int main(int argc, char *argv[])
{
  //Initialize syslog
  setlogmask(LOG_UPTO(LOG_NOTICE));
  openlog("example_process", LOG_CONS | LOG_PID | LOG_NDELAY, LOG_USER);

  while(main_loop == LOOP_CONTINUE)
    {
       syslog(LOG_ERR, "Data Logged!\n");
       syslog(LOG_ERR, "Data Logged2!\n");
       sleep(60);
    }

  closelog();
}
</code></pre>

<p>It writes every reiteration:</p>

<pre><code>Feb 11 17:43:06 andrea-Aspire-5745G example_process[7645]: Data Logged!
Feb 11 17:43:06 andrea-Aspire-5745G example_process[7645]: Data Logged2!
Feb 11 17:43:10 andrea-Aspire-5745G example_process[7645]: Data Logged!
Feb 11 17:43:10 andrea-Aspire-5745G example_process[7645]: Data Logged2!
Feb 11 17:43:13 andrea-Aspire-5745G example_process[7645]: Data Logged!
Feb 11 17:43:13 andrea-Aspire-5745G example_process[7645]: Data Logged2!
</code></pre>

<p>I understand that log every the same message is not a good idea, but here is my question:</p>

<p>Is there a method or an option to make it possible?</p>