Thank you, Kent In fact, I followed the page you posted, but it seems not working at all, maybe due to version or so.
But good hints, and I find it in Python Documentation 2.3.4. http://www.python.org/doc/2.3.4/lib/node301.html After some trials, I find the minimal ways to meet my need. Just define two handler, one through FileHandler and the other through StreamHandler. from logging import * import sys logger=getLogger('application') formatter=Formatter('%(asctime)s %(levelname)s %(message)s') handler1=FileHandler('application.log','w') handler1.setFormatter(formatter) handler2=StreamHandler(sys.stdout) handler2.setFormatter(formatter) logger.addHandler(handler1) logger.addHandler(handler2) logger.setLevel(DEBUG) logger.error('We have a problem.') logger.info('And some information.') Juan Shen å 2005å1æ21æ ææä 11:53ïKent Johnson åéï > The logging module is good for this. You can set it up to log to the screen > and a file. You have to do some setup and change your print statements to > call a logger. > > See this section of the docs and the one following for examples. > http://www.python.org/dev/doc/devel/lib/minimal-example.html > > It's easier than it looks, you just have to take a little time to figure > out how to set it up the way you like it. > > Kent > > ææå wrote: > > Hi, I'm now writing a simulation program in Python. Indeed, it's a > > time-wasting program, a complete simulation will last several days. > > Of course, the simulation result is easily stored in files, through file > > class of Python. > > > > Now, my partners require the simulation result to be printed on screen > > and to be stored in file as well, therefore they can monitor the result > > in time. I hope these two output method should be used in the mean time > > ------ not a 'print' + a 'file.write'. :) > > > > So what's the single method to hold this requirement? Wish it's quite > > basic. By the way, the platform is FreeBSD. > > Juan Shen _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor