logging to a file: how?

Having read that fprintf() is Bad (I even understand why, I think), I'm looking for different means of logging messages to a file. I found something in this link: http://www.stahlforce.com/dev/index.php?tool=mtk , but I am unsure how good that tool is (I lack perception, obviously). If soemone could tellm e whether they know this tool, or perhaps could you please tell me how to log to a file in a way that is both elegant and simple? Or, at least simple...
Last edited on
I don't really see any connection between that tool and using a log file.
I suppose the simplest way of logging to a file (unless you need to use Unicode) is this:
1
2
3
4
#include <fstream>
//...
std::ofstream logfile("log.txt");
logfile <<"I say, old bean! I must express my astonishment of your claim! Is this fact, or a clever ruse?"<<std::endl;
Er, I added a comma to the link without a space, my bad. The link should work now. But, since your method is even simpler, I'll use that one. Thanks a bunch!
Last edited on
Topic archived. No new replies allowed.