I'm trying to add some logging to my Chef recipe.
In other recipes I noticed use of Chef::Log.info
, for example:
Chef::Log.info("Connection to database '#{dbname}' on '#{host}' failed")
I was wondering what this does. The logging does not appear anywhere it seems, not in console, not in log files. Chef website also does not seem to document why and how this should be used.
Why would you want to add such a info log statement? Where can you see such messages? Does this require a premium feature?
My knife.rb
has log_level as follows
log_level :info
log_location STDOUT
You can set the log level of your chef run by setting the -l
flag. So:
chef-client -l info
will result in your info log messages appearing. Also, beware that there are two ways to do a log message. One, the method you show, will result in the message appearing during the resource gathering stage of the chef run; the other, shown below, will result in the log message appearing during the provider execution phase.
log 'my log messsage' do
level :info
end