Logging chef-client output

You can obtain chef-client logs from the nodes when you use the IBM® Cloud Manager with OpenStack commands.

The IBM Cloud Manager with OpenStack commands log chef-client console output and service status output that is captured from each node on the Chef server in a central location. The log file name includes the node name, as well as, an integer time stamp. Up to 44 log files are kept for each node in the /var/log/icm-deployer/nodes folder on the Chef server. Each IBM Cloud Manager with OpenStack deployment or update command typically writes a minimum of 4 log files per node. Two are for the bootstrap (1 *.log and 1 *.console), and the final two are for the actual chef-client run (1 *.log and 1 *.console). HA deployments write more log files, up to 13 per node.

The log file generation can be controlled by two settings in the chef server /root/.chef/knife.rb file:
knife[:node_log_max_files] = 44
knife[:node_log_path] = '/var/log/icm-deployer/nodes'

These settings default in the IBM Cloud Manager with OpenStack command-line interface code to the preceding values shown above. The preceding values can be set in knife.rb, if the defaults are not adequate.

To turn of node logging, set knife[:node_log_max_files] = 0

During deployment or an update, two log files are created for each node to which the IBM Cloud Manager with OpenStack command connects.
  • The detailed log file name is <node_name>_<timestamp>.log. For example:
    host.my.company.com_2014-10-23_06-56-24-314222499000.log
    The detailed log file contains the low-level chef-client information.
  • The console log file name is <node_name>_<timestamp>.console. For example:
    host.my.company.com_2014-10-23_06-56-24-314222499000.console
    The console log file contains the same high level chef-client information that is displayed to the terminal by the command. Each row in the file includes the time stamp of the high-level action and the number of milliseconds since the last high-level action.

By default, up to 44 log files are saved for each node.

Logging chef-client output to a log file on the node itself can also be accomplished by specifying chef-client options when you issue one of the IBM Cloud Manager with OpenStack os manage deploy or os manage update commands. When chef-client writes to a log file, it does not affect its console output.

To enter the chef-client options on a IBM Cloud Manager with OpenStack CLI 'node' type command, use the -O option followed by a string that contains the chef-client options. For example:
knife os manage update node host.my.company.com -P passw0rd -O '-l info -L /var/log/chef-client.log'
The -l chef-client option is the log level (info is specified in the preceding example). The -L chef-client option is the log file location.
Note: The log file path must exist or an error occurs when the log file is written.
To enter the chef-client options on a IBM Cloud Manager with OpenStack CLI 'topology' type command, use the chef-client-options JSON key in the topology file that contains a list of chef-client options. For example, the JSON key and value for a node in the topology file might look like the following example:
 "chef_client_options": ["-l info", "-L /var/log/chef-client.log"],
The preceding options are passed to chef-client to cause it to perform info level logging and store the log information in /var/log/chef-client.log.

When forcing the chef-client to write to a log file, the output is not the same as that seen on the console. That console output is logged on the chef server as previously mentioned.

Another option to forcing chef-client to write to a log file is to set the following values in the client.rb file on the node:
log_location "/var/log/chef-client.log"
verbose :info
log_level :info
That would cause info level logging to occur for all chef-client calls to the log file /var/log/chef-client.log.
Note: The chef-client log is not cleared. It is always appended to by chef-client.