Search code examples
chef-infratest-kitchen

How to capture Chef::Log.info in kitchen test


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,


Solution

  • 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.