How to log the error messages in a recipe.
For EX: My recipe here is
#
# Cookbook:: mkdir
# Recipe:: default
#
# Copyright:: 2018, The Authors, All Rights Reserved.
bash 'extract_module' do
code <<-EOH
mkdir -p /tmp/#{node['main']['directory']}
EOH
Chef::Log.info "Directory Created"
#puts "Directory created"
end
Where is the log file actually created ??? --> Chef::Log.info "Directory Created"
How can i control my recipe to stop if
mkdir -p /tmp/#{node['main']['directory']}
actually fails??
Thank you
I believe it depends on your operating system.
For a windows machine your logs will most likely be at the directory C:\chef\log
.
For a linux machine, it should default to /etc/chef/log
You should find log files with names like client-run_20181024124200.log
.
This log file will contain your Chef::Log.info "Directory Created"
I would like to point out that, you can actually specify where you want your logs to be written to. To do this, first navigate to and open the file C:\chef\client.rb
on a windows machine or /etc/chef/client.rb
on a linux box.
You can now change the line log_location STDOUT
to your own directory like
log_location C:\logs\cheflogs