0
votes

The following code send a message to the file /var/log/syslog. I have a remote server which is listening in port 514(rsyslog). Is there any way to change this code so it will send a message to the remote server?

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <syslog.h>

int main(int argc, char *argv[])
{

  openlog ("Engine", LOG_CONS | LOG_PID | LOG_NDELAY, LOG_LOCAL1);
  syslog(LOG_NOTICE,"***Example***");

}
1

1 Answers

0
votes

To my knowledge using openlog and syslog as you describe will log to the server configured in syslog.conf, thus you cannot specify a server the way you want. You could set up remote server in syslog.conf and that should work.

If you do not wish to do that, you either need to use a library that supports syslog as a sink, or you need to implement your own - which is not very hard.