Skip to content

Instantly share code, notes, and snippets.

@rottenbytes
Created October 16, 2013 10:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save rottenbytes/1471cf5755a0d95e0bea to your computer and use it in GitHub Desktop.
Save rottenbytes/1471cf5755a0d95e0bea to your computer and use it in GitHub Desktop.
Chef 11.6 & syslog

Why

Because the logging class has been rewritten in chef 11.6 and that the trick that consisted of adding

# log via syslog
require 'syslog_logger'
SyslogLogger.class_eval do
  attr_accessor :sync, :formatter
end

log_location SyslogLogger.new("chef-client")

in chef client config file does not work anymore

How

Add a few more lines, to trick it·

@@log_level = log_level

# log via syslog
require 'syslog_logger'
SyslogLogger.class_eval do
  attr_accessor :sync, :formatter

  def close
    true
  end

  def write(msg="")
    self.send(@@log_level, msg)
  end
end

log_location SyslogLogger.new("chef-client")

And you get your syslog back

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment