如何将来自python manage.py runserver
的日志打印到日志文件中(而不是显示在控制台内)。
这是我想要保存到日志文件中的日志示例:
Performing system checks...
System check identified no issues (0 silenced).
November 19, 2015 - 01:37:54
Django version 1.8.5, using settings 'simpatize.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
答案 0 :(得分:0)
将日志写入log.txt
中的文件C:\dev\appName
:
logger = logging.getLogger()
fh = logging.FileHandler('.\log.txt')
logger.addHandler(fh)