["python","logging","python-logging"]
How to write to a file, using the logging Python module?

How can I use the logging module in Python to write to a file? Every time I try to use it, it just prints out the message.
An example of using logging.basicConfig rather than logging.fileHandler() logging.basicConfig(filename=logname, filemode='a', format='%(asctime)s,%(msecs)03d %(name)s %(levelname)s %(message)s', datefmt='%Y-%m-%d %H:%M:%S', level=logging.DEBUG) logging.info("Running Urban Planning") logger = logging.getLogger('urbanGUI') In order, the five parts do the following: set the output file (filename=logname) set it to append (filemode='a') rather than overwrite (filemode='w') determine the format of the output message (format=...) determine the format of the output date and time (datefmt='%Y-%m-%d %H:%M:%S') and determine the minimum message level it will accept (level=logging.DEBUG).