问题
I've tried changing the logging on Savon when running it against a WSDL, but have been unsuccessful in changing the logging level.
I read the docs: http://rubiii.github.com/savon/#global_configuration
I did this:
Savon.configure do |config|
config.log = false # disable logging
config.log_level = :info # changing the log level
config.logger = Rails.logger # using the Rails logger
end
And it complains about not knowing what configure means.. any ideas?
回答1:
This documentation you linked is for savon 0.8, you may be using an older version. When in doubt, go to the source code (path is platform-dependent) and check how the code/test do it:
$ cd /usr/lib/ruby/gems/1.8/gems/savon-0.7.8
$ grep -lr log_level *
lib/savon/logger.rb
spec/savon/request_spec.rb
$ cat spec/savon/request_spec.rb
...
Savon::Request.log_level = :info
...
回答2:
At least as of gem 'savon', '~> 2.3.0'
, you can add the configuration keys when instantiating the client.
client = Savon.client(
log_level: :debug,
log: true,
pretty_print_xml: true,
wsdl: 'http://ws.cdyne.com/emailverify/Emailvernotestemail.asmx?wsdl'
)
来源:https://stackoverflow.com/questions/4217783/ruby-savon-gem-change-logging-configuration