Created
October 21, 2015 20:45
-
-
Save jsuwo/a01166bd0f6e66bb070f to your computer and use it in GitHub Desktop.
Simple syslog example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <syslog.h> | |
#include <stdlib.h> | |
#include <unistd.h> | |
int main() | |
{ | |
openlog("fig3-7", LOG_PERROR | LOG_PID | LOG_NDELAY, LOG_USER); | |
syslog(LOG_NOTICE, "Hello Syslog!"); | |
syslog(LOG_INFO, "Here's an informational message."); | |
syslog(LOG_WARNING, "Here's a warning."); | |
syslog(LOG_ERR, "Here's an error."); | |
syslog(LOG_DEBUG, "Here's some debugging information.\n"); | |
for (int i = 0; i < 10000000; ++i) | |
{ | |
syslog(LOG_DEBUG, "%i", i); | |
sleep(1); | |
} | |
closelog(); | |
exit(EXIT_SUCCESS); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fig3-7[8726]: Hello Syslog! | |
fig3-7[8726]: Here's an informational message. | |
fig3-7[8726]: Here's a warning. | |
fig3-7[8726]: Here's an error. | |
fig3-7[8726]: Here's some debugging information. | |
fig3-7[8726]: 0 | |
fig3-7[8726]: 1 | |
fig3-7[8726]: 2 | |
fig3-7[8726]: 3 | |
fig3-7[8726]: 4 | |
. | |
. | |
. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment