tags:

views:

55

answers:

2

Which way is standard to generate IETF-syslog messages in the C language?

There is the header <syslog.h>. But it provide no options to use the STRUCTURED-DATA mechanism (rfc-5424).

Of course, messages could be constructed by hand directly to a socket. But it seems that such way is not standard.

Is there another standard way?

+1  A: 

Hmmm...that rfc is less than 2 years. I don't think it is a big surprise to see that the ususal suspects haven't implemented it yet.

dmckee
A: 

The standard way to do this is to have your application log messages using the normal openlog(), syslog() and closelog() routines from <syslog.h>.

That will send the messages to the syslogd running on the local machine. If the messages are then to be forwarded over the network using the syslog protocol, syslogd itself will take care of this. For example, this might be done using a target like @hostname in the syslogd.conf file.

In short, your application is expected to log messages to the syslogd, and syslogd decides where to send them (including over the network). This allows the local administrator maximum control.

caf