Write records to system logs under ubuntu-general Linux technology-Linux programming and kernel information. The following is a detailed description. Do you want linux system logs to write down what your program has done? Haha, use the following program. It can help you write the things you want to record to/var/log/syslog. Don't believe it.
CODE: # include // When the program cannot run, restart the syslog process:/etc/init. d/sysklogd restart. # Include # Include # Include # Include # Include Main () // tail-f/var/log/syslog To view log Dynamics { Time_t now; // system time function settings Int y = 0; Syslog (LOG_USER | LOG_DEBUG, "daemon test! \ N "); // write text to the log file While (1) While (y <3072) // stop writing logs when the log file is greater than 3 K { Struct stat x; // defines the struct variable Stat ("/var/log/syslog", & x); // call a function Y = x. st_size; // obtain the syslog size. Printf ("the size is: % d \ n", y ); Time (& now); // system time function settings Syslog (LOG_USER | LOG_INFO, "Xiong Feng reminds you that the current time is \ t % s \ t \ n", ctime (& now); // write text to the log file Sleep (3); // trigger once every three seconds } } |