Prev: Classes as namespaces?
Next: Income for life !
From: Ovidiu Deac on 26 Mar 2010 12:26 Anyway, thanks for the first part. Anybody else has any idea why using the same configuration file works when running the tests with nosetests and doesn't work with logging.config.fileConfig() ?
From: Vinay Sajip on 26 Mar 2010 15:09 On Mar 26, 4:26 pm, Ovidiu Deac <ovidiud...(a)gmail.com> wrote: > Anyway, thanks for the first part. > > Anybody else has any idea why using the same configuration file works > when running the tests with nosetests and doesn't work withlogging.config..fileConfig() ? It's probably because the fileConfig code is intended to *replace* any existing configuration. This means disabling any existing loggers which are not named explicitly, or not descendants of loggers named explicitly, in the configuration. Make sure you call logging.config.fileConfig() before any loggers have been instantiated in your code, or else ensure that all the top-level parents of those loggers (i.e. just below the root logger) are defined in the configuration. If you have version 2.6 or newer of Python, the fileConfig call has an optional keyword parameter disable_existing_loggers which has a default value of True, but which you can set to False to avoid disabling the existing loggers. Regards, Vinay Sajip
From: Ovidiu Deac on 26 Mar 2010 16:08 It worked. Setting disable_existing_loggers=False fixed my problem. Thanks to both of you! Ovidiu On Fri, Mar 26, 2010 at 9:09 PM, Vinay Sajip <vinay_sajip(a)yahoo.co.uk> wrote: > On Mar 26, 4:26 pm, Ovidiu Deac <ovidiud...(a)gmail.com> wrote: >> Anyway, thanks for the first part. >> >> Anybody else has any idea why using the same configuration file works >> when running the tests with nosetests and doesn't work withlogging.config.fileConfig() ? > > It's probably because the fileConfig code is intended to *replace* any > existing configuration. This means disabling any existing loggers > which are not named explicitly, or not descendants of loggers named > explicitly, in the configuration. > > Make sure you call logging.config.fileConfig() before any loggers have > been instantiated in your code, or else ensure that all the top-level > parents of those loggers (i.e. just below the root logger) are defined > in the configuration. > > If you have version 2.6 or newer of Python, the fileConfig call has an > optional keyword parameter disable_existing_loggers which has a > default value of True, but which you can set to False to avoid > disabling the existing loggers. > > Regards, > > Vinay Sajip > -- > http://mail.python.org/mailman/listinfo/python-list >
|
Pages: 1 Prev: Classes as namespaces? Next: Income for life ! |