[chef] Re: RE: Re: Logging chef-client activity to syslog - how?


Chronological Thread 
  • From: Jesse Campbell < >
  • To: chef < >
  • Subject: [chef] Re: RE: Re: Logging chef-client activity to syslog - how?
  • Date: Mon, 24 Dec 2012 12:46:23 -0500

chef's config checker requires that whatever object is passed into log_location either be a file (as specified by a string), or be an object that responds to the sync= setter.
I have no idea what sync is supposed to do, but at the moment I don't much care :)

With the latest (2.0) version of SyslogLogger, put this in your client.rb to get it to work:

require 'syslog/logger'
class Syslog::Logger
  attr_accessor :sync
end
log_level        :info
log_location     Syslog::Logger.new("chef-client")

Thanks for pushing me to poke at this, this will clean up a few of my processes.


On Mon, Dec 24, 2012 at 9:27 AM, Chris Sibbitt < " target="_blank"> > wrote:

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: " target="_blank"> ]
Sent: Friday, December 21, 2012 7:40 PM
To: chef
Subject: [chef] Re: Logging chef-client activity to syslog - how?

 

Ooh! this would be perfect if it worked.
I'm currently modifying the chef-client recipe to pipe all output to /usr/bin/logger. Please post if you get it to work?

 

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.

§