Setting log levels in puppet.conf

1,917 views
Skip to first unread message

Josh Cooper

unread,
Nov 4, 2014, 4:46:18 PM11/4/14
to puppe...@googlegroups.com
Stefan Goethals added the ability to specify puppet's log_level in puppet.conf[1] and it will be available in Puppet 4.0. This was originally redmine ticket #4761, so thank you Stefan for resolving that!

I did run into one surprise and wanted to get feedback. If you specify log_level=debug in puppet.conf, and run with `puppet agent --verbose` (or more commonly `puppet agent --test`, which implies `--verbose` and a bunch of other settings), then the agent's log_level will be reset back down to the info level, and you won't get any debug output.

To see debug output, you have to execute `puppet agent --test --debug` or specify a lot of the things `--test` implies, but leave out `--verbose`, e.g `puppet agent --no-daemonize --onetime`

The problem originates in Puppet::Application#set_log_level

    if options[:debug]
      Puppet::Util::Log.level = :debug
    elsif options[:verbose]
      Puppet::Util::Log.level = :info
    end

The code assumes that if debug is not specified on the command line, but verbose is, then the log level must be info. If the log level is set to debug in puppet.conf, then this will actually downgrade the logging level to info.

We could fix this a few different ways.

1. If --verbose (or --test) is specified, then ensure the log_level is *at least* at the info level
2. Change --test to imply --debug instead of --verbose
3. Something else?

Josh

David Schmitt

unread,
Nov 5, 2014, 1:54:04 AM11/5/14
to puppe...@googlegroups.com
Commandline options should always trump config file settings for reduced
surprise factor.


Regards, David

--
* Always looking for people I can help with awesome projects *
Twitter: @dev_el_ops G+: https://plus.google.com/+DavidSchmitt
Blog: http://club.black.co.at/log/
LinkedIn: http://at.linkedin.com/in/davidschmitt

Michael Smith

unread,
Nov 5, 2014, 3:58:18 AM11/5/14
to puppe...@googlegroups.com
I agree, though I like changing the definition of --test to be at least --info instead of exactly (solution 1). It makes the behavior more useful.

Sent from my iPad
> --
> You received this message because you are subscribed to the Google Groups "Puppet Developers" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to puppet-dev+...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-dev/5459C983.1060605%40dasz.at.
> For more options, visit https://groups.google.com/d/optout.

Jim Toth

unread,
Nov 5, 2014, 9:44:53 AM11/5/14
to puppe...@googlegroups.com
On Wed, Nov 5, 2014 at 1:53 AM, David Schmitt <da...@dasz.at> wrote:
Commandline options should always trump config file settings for reduced surprise factor.

I agree, but in this case, the fact that --verbose would ever *decrease* the log level *is* the surprising thing.


I expect

puppet verb1 --verbose --blah1 --blah2 --debug

to do the same thing as

puppet verb1 --debug --blah1 --blah2 --verbose

Now, I *would* expect

puppet verb1 --loglevel debug --blah1 --blah2 --loglevel info

to not be logging anything higher than info, just as I expect

rm -f -r -i /bin

to be asking me about every single file.  Later command line options should trump earlier ones.  (In case it's not clear, to me, "in the config file" just means "It's earlier on the command line".)


And back to the orignal question:
1. If --verbose (or --test) is specified, then ensure the log_level is
*at least* at the info level

Yes, option 1.

 

--

Joshua Hoblitt

unread,
Nov 5, 2014, 9:46:14 AM11/5/14
to puppe...@googlegroups.com
On 11/04/2014 11:53 PM, David Schmitt wrote:
>
> Commandline options should always trump config file settings for
> reduced surprise factor.
^^^ This

-Josh

--

David Schmitt

unread,
Nov 5, 2014, 12:10:23 PM11/5/14
to puppe...@googlegroups.com
True. Making "--test" a "must be at least info", instead of exactly
equal makes sense and doesn't violate my statement.

D.

Erik Dalén

unread,
Nov 6, 2014, 8:25:34 AM11/6/14
to puppe...@googlegroups.com
Note that --test is implemented in both agent and apply, so make sure to change it in both places.

>> To unsubscribe from this group and stop receiving emails from it, send an email to puppet-dev+unsubscribe@googlegroups.com.

>> To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-dev/5459C983.1060605%40dasz.at.
>> For more options, visit https://groups.google.com/d/optout.
>


--
* Always looking for people I can help with awesome projects *
Twitter: @dev_el_ops G+: https://plus.google.com/+DavidSchmitt
Blog: http://club.black.co.at/log/
LinkedIn: http://at.linkedin.com/in/davidschmitt

--
You received this message because you are subscribed to the Google Groups "Puppet Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to puppet-dev+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-dev/545A59F5.4070906%40dasz.at.

Felix Frank

unread,
Nov 7, 2014, 9:19:10 AM11/7/14
to puppe...@googlegroups.com
On 11/04/2014 10:46 PM, Josh Cooper wrote:
> 2. Change --test to imply --debug instead of --verbose

I don't think this is an option.

Many users are likely in the habit of using --test whenever actually
testing or even manually running the catalog from the master. The
percentage of those that would want to get the debug details all over
their terminals each and every time is most likely insignificant.
Reply all
Reply to author
Forward
0 new messages