C、Perl、Python でのsyslogのサンプル。
#include <stdlib.h>
#include <syslog.h>
int main(int argc, char** argv){
openlog(argv[0], LOG_PID|LOG_PERROR, LOG_LOCAL0);
syslog(LOG_INFO, "foo: %d", 123);
closelog();
exit(EXIT_SUCCESS);
}
#!/usr/bin/perl
use strict;
use warnings;
use Sys::Syslog;
sub EXIT_SUCCESS{0}
openlog(__FILE__, 'pid,perror', 'local0');
syslog('info', "foo: 123" );
closelog;
exit(EXIT_SUCCESS);
#!/usr/bin/python
import sys
import syslog
def main():
syslog.openlog(sys.argv[0], syslog.LOG_PID|syslog.LOG_PERROR, syslog.LOG_LOCAL0)
syslog.syslog(syslog.LOG_INFO, 'foo:%s' %(123,))
syslog.closelog()
sys.exit(0)
if __name__ == "__main__":
main()