import logging import os import web def is_test(): if 'WEBPY_ENV' in os.environ: return os.environ['WEBPY_ENV'] == 'test' app = web.application(router.urls, globals()) logging.basicConfig(filename="log/debug.log", level=logging.INFO) global logger logger = logging.getLogger("debug") if (not is_test()) and __name__ == "__main__": app.run() logger = logging.getLogger("debug") global logger logger = logging.getLogger("debug") my_debug_logger = logging.getLogger("debug") my_debug_logger.info('some message')