This is the best I’ve got so far; not much better than piping to logger I’m afraid: log_location open("| ruby -e \"require 'syslog'; Syslog.open 'chef-client'; while gets: Syslog.info sub /^.*?\\[.*?\\] /, '' end\"", 'w'); It’s a cheap hack, but it meets my operational requirement so until I have time to rip apart the rest of the logging code it will have to do. The biggest drawback
is probably the fact that it maps all logged output to the INFO priority no matter what it was originally. Would still appreciate help with doing this the “right” way. From: Jesse Campbell [mailto:
Ooh! this would be perfect if it worked. On Thu, Dec 20, 2012 at 5:45 PM, Chris Sibbitt <
" target="_blank">
> wrote: Hello, I am trying to get chef-client to log to syslog. I am running 10.16.2 and I have found info about this in the JIRA system (http://tickets.opscode.com/browse/CHEF-273) I installed SyslogLogger and tested it with a simple check script that works just fine:
require 'rubygems'
require 'syslog_logger'
logobj = SyslogLogger.new("chef-client")
logobj.info('test') This is my client.rb:
require 'syslog_logger'
log_level :info
log_location SyslogLogger.new("chef-client")
chef_server_url 'http://MYCHEFSERVER:4000'
validation_client_name 'chef-validator' When I run chef-client I get nothing in syslog, so I tried this client.rb based on a snippet I stumbled across at random (https://gist.github.com/787164)
require 'syslog_logger'
Chef::Log.logger = SyslogLogger.new("chef-client")
log_level :info
Chef::Log.logger.info("Sanity Check")
log_location STDOUT
chef_server_url 'http://MYCHEFSERVER:4000'
validation_client_name 'chef-validator' Running chef-client results in “Sanity Check” in my logs, but nothing after that. I suspected a bug like this one (http://tickets.opscode.com/browse/CHEF-1985
) and instrumented the chef-client source code enough to see that indeed the custom log destination works right up until init() is called in mixlog, but I’m not yet very adept at ruby and didn’t get to the bottom of it this way. I tried a variety of other syslog gems as well with various combinations and could not find anything that works. The tickets suggest that logging to syslog is supported, and even that it is the default behavior, but I just can’t get it to work. Can someone point out what I am doing wrong or
suggest something to try? |
Archive powered by MHonArc 2.6.16.