8

When I run

   kitchen test

or

   kitchen test --log-level info

No logs that I have in my recipe under test ie.

   Chef::Log.info("How to make appear in kitchen output?")

are displayed in kitchen's output to console. Anyway to make this happen?

driver: vagrant

provisioner: chef-solo

Thanks,

MikeW
  • 4,749
  • 9
  • 42
  • 83

2 Answers2

13

Update: Martin's answer is no longer true as of version 1.7.0 of Test Kitchen (See pull request #950).

According to the Dynamic Configuration doc, "Since Kitchen 1.7.0 the log level for the provisioner is no longer related to the Kitchen log level."

It gives the following example of setting the log_level in .kitchen.yml:

provisioner: name: chef-zero log_level: <%= ENV['CHEF_LOG_LEVEL'] || auto %>

My tests confirm that:

  • Chef::Log.debug calls aren't logged when simply running kitchen converge -l debug.
  • Chef::Log.debug calls are logged after setting log_level: debug in .kitchen.yml.
David P
  • 761
  • 8
  • 13
  • Note that the log_level option is not currently documented in the [.kitchen.yml syntax doc](https://docs.chef.io/config_yml_kitchen.html). See also [v1.7.0 entry in the CHANGELOG](https://github.com/test-kitchen/test-kitchen/blob/master/CHANGELOG.md#v170-2016-04-01) – David P May 05 '17 at 05:11
1

You can set the verbose level when running test-kitchen, e.g. kitchen test -l debug. What you're seeing is that by default, Chef runs at WARN and higher, so by default, INFO is hidden. This is true with chef-client as well. Using -l debug on your kitchen command will pass -l debug to the chef-client command, and then you'll see INFO-level logs too.

Martin
  • 2,815
  • 1
  • 21
  • 30
  • 1
    Hi - I've tried this but still aren't seeing any logs from the recipe - does this apply to chef-solo ? -- actually disregard - docs say it does - ill try a few different log levels and see what happens – MikeW Sep 23 '15 at 02:03
  • I use this all the time, so I'm pretty sure that is correct. I only use it with `-l debug` though. – Martin Sep 23 '15 at 11:10