How can one change the formatting of output from the logging
module in Google App Engine?
I've tried, e.g.:
log_format = "* %(asctime)s %(levelname)-8s %(message)s"
date_format = "%a, %d %b %Y %H:%M:%S"
console = logging.StreamHandler()
fr = logging.Formatter(log_format)
console.setFormatter(fr)
logger = logging.getLogger()
logger.addFilter(SuperfluousFilter())
logger.addHandler(console)
logger.setLevel(logging.DEBUG)
console.setLevel(logging.DEBUG)
logging.error("Reconfiguring logging")
However this results in duplicate logging output: One with the logging handler from google/appengine/tools/dev_appserver.py
(or somewhere in the Google code), and one from my new StreamHandler
above. The above code outputs:
ERROR 2010-06-23 20:46:18,871 initialize.py:38] Reconfiguring logging 2010-06-23 20:46:18,871 ERROR Reconfiguring logging
Where the top line is clearly from dev_appserver.py
, the bottom line from my code.
So I guess the corollary question is: How can change the formatting of Google App Engine, yet avoid the duplicate output?
Thank you for reading.
Brian