How to create Log file for my VS Solution?
I am working on VS 2008. My solution has a lot of projects and each project, a number of source files. I want to log the entry and exit (using fprintf) from the functions inside the source files. How do I create a global F开发者_开发问答ILE variable and where do I open (fopen) it in order to accomplish this. I am working on C++.
Take a look at some logging library instead of using plain FILE*
. E.g., take a look at list of log4j ports.
Log(char* pString){
FILE *fp;
fp = fopen("DataLog.txt", "a");
if( fp == NULL ){
fclose(fp);
}
fprintf( fp, "LOG :%s\n", pString );
fflush(fp);
fclose(fp);
}
精彩评论