所以我有一个Linux系统上运行的守护进程,我想记录它的活动:日志。问题是,完成这个任务的“最佳”方法是什么?Linux中的守护进程日志记录
我的第一个想法是简单地打开一个文件并写入它。
FILE* log = fopen("logfile.log", "w");
/* daemon works...needs to write to log */
fprintf(log, "foo%s\n", (char*)bar);
/* ...all done, close the file */
fclose(log);
这种方式有什么天生的错误吗?有没有更好的方法,比如一些嵌入到Linux中的框架?
“man 3 ...”!我不知道这件事。 – codemonkey 2008-10-01 17:00:47