Logger should be got by oslo.log getLogger instead of logging package

Bug #1788119 reported by Yang Youseok
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
oslo.messaging
Confirmed
Undecided
Ken Giusti

Bug Description

I was trying to off log message in oslo.messaging package using `default_log_level` in config file, but debug message from oslo.messaging keep emitting.

After I dig the source, some modules like _drivers/amqpdriver.py did not use getLogger in oslo.log package, so user could not set log level for the module.

Åt the same time, module like _drivers/impl_rabbit.py do use oslo.log getLogger so that I can set the log level normally.

I'm not sure it's intentional, but it seems to be bug since user expect the `default_log_level` affect the entire library package.

Ken Giusti (kgiusti)
Changed in oslo.messaging:
status: New → Confirmed
assignee: nobody → Ken Giusti (kgiusti)
Revision history for this message
Ken Giusti (kgiusti) wrote :

Your observations are correct.

I talked a bit with Doug Hellman regarding what you're seeing. Way back we 'de-namespaced' the modules such that "oslo.messaging" became "oslo_messaging". This created problems for folks that had "oslo.messaging=<WHATEVER>" in their default_log_levels setting since the module name changed to 'oslo_messaging' and their log setting were being ignored.

To help fix that a workaround was added to oslo.log:

http://git.openstack.org/cgit/openstack/oslo.log/tree/oslo_log/log.py#n446

So whenever oslo_log's getLogger is called it converts the name "oslo_messaging" to "oslo.messaging". However as you noticed some of the oslo.messaging files use the python library's getLogger, which doesn't do the translation and will not filter based on "oslo.messaging=<WHATEVER>"

So this is indeed a bug in oslo.messaging (as far as I'm concerned).

Workaround: include both "oslo.messaging=<WHATEVER>" and "oslo_messaging=<WHATEVER>" in your default_log_levels (note the '_' vs '.')

Revision history for this message
Yang Youseok (ileixe) wrote :

Yes, I found the related code in oslo.log and expected maybe there was historical reason for the code. :)

Imho, before the oslo.log changed the default value of default_log_level config to use "oslo_messaging", it's better to use logging in oslo.log for the other modules.

I found oslo.cache which is specified in "default_log_level" also only use the logger got from oslo.log.

How about that?

Revision history for this message
Ken Giusti (kgiusti) wrote :

Adding in Doug who has more context on the oslo.log change.

Background:

The original bug:
https://bugs.launchpad.net/mos/+bug/1484501

See Doug's comment here:
https://review.openstack.org/#/c/213795/2/oslo_log/log.py

Looks like "oslo_messaging" was added to the defaults by this patch:

https://review.openstack.org/#/c/458069/

From Doug's comment on log.py it appears that the "oslo.<xxx>" format is the desired format.

The addition of "oslo_messaging" to the defaults appears to be a work around to oslo.messaging's inconsistent use of logging.

IMHO all oslo.<whatever> modules that have a dependency on oslo.log should use oslo.log for all logging. Using both oslo.log and py logging by the same module should be a bug (unless there's a specific use case requirement - like notification logging).

So if oslo.cache is using both oslo.log and py logging it should be fixed to use only oslo.log.

Doug - what say ye?

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.