简单C++类: void My_Log::Write_Log(const char *szFormat, ...) { FILE *hf = NULL; va_list ap; if(!szLogFile[0]) return; hf = fopen(szLogFile, "a"); if(!hf) return; va_start(ap, szFormat); vfprintf(hf, szFormat, ap); va_end(ap); fprintf(hf, "\n"); fflush(hf); fclose(hf); }