I want to create log func for my server.
I choose this way: when server starts,I open a logfile by OPEN_ALWAYS,Then any request access,write file by append method.While server stop,close logfile handle.

Now there is a question:
I don't know how could I write by append method.

I couldn't find append method of WriteFile in Win32API manual.
Could anyone show me how to do?


Posted on 2002-01-05 08:34:45 by xqterry

You can use SetFilePointer (using FILE_END as fourth parameter) to go to the end of your log file and write on it.
Posted on 2002-01-05 09:13:57 by JCP

thanks for your help.
Posted on 2002-01-05 11:49:49 by xqterry
Here is another option: you could use something like Ernie's debug macros (here) to put together your log file. The advantages? They are damn good, and damn easy to use. You would have alter the macro that opens the logfile so that it appends, but that is a very simple matter (if you use his code commercially, you would have to obtain a license off him first though). Using his macros, your logging lines would look something like this:

DLog "any old literal string here"
DLogValH eax, "the value of eax is:"

In case you can't tell, i love these macros, and they can make your job real simple :)
Posted on 2002-01-06 05:16:40 by sluggy
sluggy: remember that they are *debug* macros, they pushad/popad before and after the log call to preserve all registers, which isn't effecient when using it as log macros.
But you could remove the pushad/popads from the macros..

Posted on 2002-01-06 05:50:54 by Thomas
thanks,i think i would like it more and more.

thanks for tips, i tried to remove those protect.

Posted on 2002-01-06 09:34:53 by xqterry