Python日志记录调试级别不会消失

时间:2018-07-06 12:24:17

标签: python logging scripting

我正在尝试在运行某些命令时似乎已触发的Python 2.6.6中禁用DEBUG日志...并且我尝试了似乎所有解决方案都存在的问题,但我仍然不断得到不需要的输出。

我什至包括了

logging.disable(logging.CRITICAL)

结果相同...

当我通过cmd提示符运行相同的命令(test.cmd)时,得到了预期的输出。当我通过python脚本运行相同的命令时,使用以下代码:

p = Popen([test, "report"], stdin=PIPE, stdout=PIPE, stderr=STDOUT)
output = p.stdout.read()
print output

我得到以下信息(而且还在继续):

07/06/18 08:13:16 DEBUG : Enter:  HTTPSender::invoke
Enter:  HTTPSender::invoke
07/06/18 08:13:16 DEBUG : XML sent:
XML sent:
07/06/18 08:13:16 DEBUG : ---------------------------------------------------
---------------------------------------------------
07/06/18 08:13:16 DEBUG : POST /awstestservice/soap HTTP/1.0
Content-Type: text/xml; charset=utf-8
Accept: application/soap+xml, application/dime, multipart/related, text/*
User-Agent: Axis/1.4
Host: localhost
Cache-Control: no-cache
Pragma: no-cache
SOAPAction: "awstestReport"
Content-Length: 327

有什么想法吗?

1 个答案:

答案 0 :(得分:0)

我最终写出了以下解决方法:

#Verify the report was created
output = p.stdout.read()
status = output.rfind('Report created')

#Update Report Status
if (status!=-1):
 print ("Report Created")
else:
print ("Error")

不确定是否可以帮助任何人,但是它解决了我的问题...

相关问题