我这里有这段代码,预计将输出文本“写入日志”。每次访问../write_to_log页面时,将其保存到“ output-logs / {name}”目录中的“ {name} _Output.txt”文件中。文本在控制台中正确显示,并且日志文件在正确的目录位置生成,但是没有任何内容写入文件本身。任何想法将不胜感激。
/* start update */
nav ul {
margin-bottom: 0;
}
.navbar-light .navbar-toggler-icon {
background-image: none;
font-size: 25px;
height: auto;
width: auto;
padding: 3px;
}
@media(max-width: 768px) {
#navbarCollapse ul li {
display: block !important;
padding: 0;
margin: 0;
}
#navbarCollapse ul {padding-top:10px}
#navbarCollapse ul li a {
margin: 0;
padding: 5px 10px;
}
nav {position: relative}
nav form {
position: absolute;
top: 7px;
right: 15px;
}
}
/* end update */
答案 0 :(得分:0)
从Python导入日志记录模块并正确设置记录器。仔细检查官方Python日志:Logging HOW To - How to Log to a file
import logging
logging.basicConfig(filename='example.log',level=logging.DEBUG)
logging.debug('This message should go to the log file')
logging.info('So should this')
logging.warning('And this, too')