Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby Cucumber/Savon忽略或删除日志输出_Ruby_Logging_Cucumber_Savon - Fatal编程技术网

Ruby Cucumber/Savon忽略或删除日志输出

Ruby Cucumber/Savon忽略或删除日志输出,ruby,logging,cucumber,savon,Ruby,Logging,Cucumber,Savon,在运行cucumber测试时,我(除了测试结果之外)获得了大量与调试/日志相关的输出,其形式如下: D, [2013-03-06T12:21:38.911829 #49031] DEBUG -- : SOAP request: D, [2013-03-06T12:21:38.911919 #49031] DEBUG -- : Pragma: no-cache, SOAPAction: "", Content-Type: text/xml;charset=UTF-8, Content-Length

在运行cucumber测试时,我(除了测试结果之外)获得了大量与调试/日志相关的输出,其形式如下:

D, [2013-03-06T12:21:38.911829 #49031] DEBUG -- : SOAP request:
D, [2013-03-06T12:21:38.911919 #49031] DEBUG -- : Pragma: no-cache, SOAPAction: "", Content-Type: text/xml;charset=UTF-8, Content-Length: 1592
W, [2013-03-06T12:21:38.912360 #49031]  WARN -- : HTTPI executes HTTP POST using the httpclient adapter
D, [2013-03-06T12:21:39.410335 #49031] DEBUG -- : <?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
...

但是当我运行cucumber测试时,日志仍然显示出来。

通过查看的文档,您似乎能够通过执行以下操作使日志静音:

Savon.configure do | config|
config.log=false
结束

上面的代码片段可以放在您的或
features/support/env.rb
中,以使Cucumber中的日志静音。

日志对于调试可能很有用。因此,与其完全沉默,不如将它们放在rails日志中

下面是如何在savon 2中实现这一点:

# config/initializers/savon.rb
HTTPI.logger = Rails.logger

# when initializing client
@client = Savon.client wsdl: '...', logger: Rails.logger

您使用的是什么版本的Savon?2.1.0? 我希望您已经检查了savon(1.2.0)。必须使用这个版本(这是一个依赖于第三方)谢谢,这与实现我想要的。
# config/initializers/savon.rb
HTTPI.logger = Rails.logger

# when initializing client
@client = Savon.client wsdl: '...', logger: Rails.logger