cinder python module logger collides with my logger

asked 2016-05-25 04:49:19 -0600

jlausuch gravatar image

updated 2016-05-25 04:56:54 -0600

I want to have log handling in a script I'm writing, but when I import cinderclient python module I get duplicated log outputs. This is the script:

import logging

#from cinderclient.v2 import client as cinderclient

logger = logging.getLogger("test")
formatter = logging.Formatter('%(asctime)s - %(name)s - '
                              '%(levelname)s - %(message)s')
ch = logging.StreamHandler()
logger.debug("this is a test...")

This is the output when I execute this script without importing cinder module:

2016-05-25 09:43:26,753 - test - DEBUG - this is a test...

But when I uncomment the cinder import line:

2016-05-25 09:44:47,375 - test - DEBUG - this is a test...
DEBUG:test:this is a test...

I get a second output without my predefined formatting.

My cinder client is python-cinderclient (1.7.0). And this doesn't happen with nova/neutron (from neutronclient.v2_0 import client as neutronclient or from novaclient import client as novaclient).

Does anyone know why?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2016-06-02 03:14:36 -0600

jlausuch gravatar image

updated 2016-06-02 03:14:52 -0600

The solution is :

logger = logging.getLogger("test")
self.logger.propagate = 0
edit flag offensive delete link more

Get to know Ask OpenStack

Resources for moderators

Question Tools

1 follower


Asked: 2016-05-25 04:49:19 -0600

Seen: 114 times

Last updated: Jun 02 '16