python logging writes an empty file

Ovidiu Deac ovidiudeac at gmail.com
Fri Mar 26 16:08:14 EDT 2010


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 at yahoo.co.uk> wrote:
> On Mar 26, 4:26 pm, Ovidiu Deac <ovidiud... at 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
>



More information about the Python-list mailing list