Skip to content

Instantly share code, notes, and snippets.

@makotoshimazu
Created May 12, 2014 02:39
Show Gist options
  • Save makotoshimazu/5a91ddc5e0ced72fff2e to your computer and use it in GitHub Desktop.
Save makotoshimazu/5a91ddc5e0ced72fff2e to your computer and use it in GitHub Desktop.
syslog関数を利用してsyslogにログを吐いてみるテスト。 userのfacilityのログが出るように、(ubuntu14.04では)/etc/rsyslog.d/50-default.confを編集する必要がある。
#include <stdio.h>
#include <syslog.h>
int main(void)
{
printf("Hello World!\n");
openlog("testmsg", LOG_CONS|LOG_PID, LOG_USER);
syslog(LOG_WARNING, "Hello World!\n");
closelog();
printf("syslog is closed\n");
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment