我试图通过扭曲服务现有的烧瓶应用程序。如果我通过apache运行应用程序,相同的代码可以正常生成并生成日志。但是,在扭曲的情况下,应用程序运行正常,但没有日志。
Twisted的tac文件如下所示。我主要是从here复制了它。
文件: flask.tac
from freshn import flipn # The flask app
# Create and start a thread pool,
wsgiThreadPool = ThreadPool()
wsgiThreadPool.start()
# ensuring that it will be stopped when the reactor shuts down
reactor.addSystemEventTrigger('after', 'shutdown', wsgiThreadPool.stop)
# Create the WSGI resource
wsgiAppAsResource = WSGIResource(reactor, wsgiThreadPool, flipn)
# Hooks for twistd
application = service.Application('Twisted.web.wsgi Hello World Example')
server = strports.service('tcp:8080', server.Site(wsgiAppAsResource))
server.setServiceParent(application)
我用来运行的命令是
twistd -ny flask.tac
以下是用于初始化烧瓶中记录器的代码:
文件: init .py
flipn = Flask(__name__)
current_dir = os.path.abspath(os.path.dirname(__file__))
log_file = os.path.join(current_dir,'threadflask.log')
file_handler = RotatingFileHandler(log_file, maxBytes=10000, backupCount=1)
file_handler.setLevel(logging.INFO)
flipn.logger.addHandler(file_handler)
flipn.logger.info("Logging exceptions to %s" % log_file)
每次都会创建日志文件,但该文件仍为空。有什么指针吗?