Hi Reuben,
Yes, I think the logging module is the best way to do it.
And it's pretty easy, see this minimal example:
import logging
logging.basicConfig(filename="foo.log", level=logging.DEBUG)
logging.debug("This is a log message")
The log levels are a great way, to control how much will be logged. So
you can turn off debug messages by increasing the log level (e.g. to
logging.INFO).
Note: The above code is just a minimal example. The logging module is
much more powerful. For example, you could use different loggers for
different parts of you program.
Regards,
Tobias
On 12/15/2013 06:43 PM, Reuben wrote:
Hi,
What is the best way to log the output of a python script execution.
Do we need to use the logging module of python?
Regards,
Reuben
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor