Logging not being configured from config file

Bug #897376 reported by Jay Pipes
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
OpenStack Identity (keystone)
Fix Released
Low
Jay Pipes

Bug Description

Trying to track down issues with most recent version of Keystone not working in Glance's functional integration tests any more...

Turns out logging doesn't seem to be getting configured properly:

jpipes@uberbox:~/repos/glance$ tools/with_venv.sh keystone /tmp/test.53878/etc/auth.conf
Traceback (most recent call last):
  File "/home/jpipes/repos/glance/.glance-venv/bin/keystone", line 7, in <module>
    execfile(__file__)
  File "/home/jpipes/repos/glance/.glance-venv/src/keystone/bin/keystone", line 59, in <module>
    'keystone-legacy-auth', options, args)
  File "/home/jpipes/repos/glance/.glance-venv/src/keystone/keystone/common/config.py", line 323, in load_paste_app
    setup_logging(options, conf)
  File "/home/jpipes/repos/glance/.glance-venv/src/keystone/keystone/common/config.py", line 173, in setup_logging
    logfile = logging.FileHandler(logfile)
  File "/usr/lib/python2.7/logging/__init__.py", line 893, in __init__
    StreamHandler.__init__(self, self._open())
  File "/usr/lib/python2.7/logging/__init__.py", line 912, in _open
    stream = open(self.baseFilename, self.mode)
IOError: [Errno 2] No such file or directory: '/var/log/keystone/keystone-legacy-auth.log'
jpipes@uberbox:~/repos/glance$ cat /tmp/test.53878/etc/auth.conf | grep log_file
log_file = /tmp/test.53878/auth.log

As you can see, keystone doesn't seem to be honouring the log_file setting in the supplied configuration file and instead tries to find a log file in /var/log/keystone/keystone-legacy-auth.log.

Could someone let me know if this changed recently and/or how to fix?

Thanks,
-jay

Revision history for this message
Jay Pipes (jaypipes) wrote :

After looking into the code, I see this in keystone.common.config.load_paste_app:

    conf_file, conf = load_paste_config(app_name, options, args)

    try:
        # Setup logging early, supplying both the CLI options and the
        # configuration mapping from the config file
        options['log_file'] = "%s.log" % app_name
        setup_logging(options, conf)

and in setup_logging:

    # grab log_file and log_dir from config; set to defaults of not already
    # defined
    logfile = options.get('log_file') or conf.get('log_file', DEFAULT_LOG_FILE)
    logdir = options.get('log_dir') or conf.get('log_dir', DEFAULT_LOG_DIR)

    logfile = os.path.join(logdir, logfile)
    logfile = logging.FileHandler(logfile)

So, by setting options['log_file'] in load_paste_app, Keystone is essentially overriding anything set in the config file :(

Changing the options['log_file'] = ... line to this:

        if not conf.get('log_file'):
            options['log_file'] = "%s.log" % app_name

Solves the problem.

-jay

Jay Pipes (jaypipes)
Changed in keystone:
assignee: nobody → Jay Pipes (jaypipes)
status: New → Triaged
importance: Undecided → Low
Revision history for this message
Alan Pevec (apevec) wrote :

This was a side-effect of LP 844959
patch author mentioned it in https://bugs.launchpad.net/keystone/+bug/844959/comments/3

Revision history for this message
Openstack Gerrit (openstack-gerrit) wrote : Fix merged to keystone (master)

Reviewed: https://review.openstack.org/1936
Committed: http://github.com/openstack/keystone/commit/d9f9501f36912f3e26aaafb55e5dc19c9bcea909
Submitter: Jenkins
Branch: master

 status fixcommitted
 done

commit d9f9501f36912f3e26aaafb55e5dc19c9bcea909
Author: Jay Pipes <email address hidden>
Date: Mon Nov 28 19:45:01 2011 -0500

    Fixes a number of configuration/startup bugs

    LP Bug#897376 - log_file in configuration file not respected

    Adds a check to ensure that the log_file in the configuration
    file, if set, is not overridden by the default options['log_file']
    value set in keystone.common.configu.load_paste_app()

    LP Bug#897382 - service_ssl not safely checked for existence

    Added safe checks for a number of SSL-related variables in
    bin/keystone to help support easy migration for existing
    configuration files that did not have the SSL options in them.

    LP Bug#897397 - bin/keystone-auth does not respect service_port
                    or service_host

    Replicates the same behaviour that is in keystone-admin into
    keystone-auth so that it recognizes service_host and service_port
    instead of only bind_host and bind_port. This enables you to
    pass the main keystone.conf file to keystone-auth and it will
    not bomb.

    Note: keystone.common.config should go away once openstack.common.config
    is a reality...

    Change-Id: If2dfa57ba00758144219f8c1d42c05e56ed44ca2

Changed in keystone:
status: Triaged → Fix Committed
Thierry Carrez (ttx)
Changed in keystone:
milestone: none → essex-2
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in keystone:
milestone: essex-2 → 2012.1
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.