Issue 10637

Using logging config file suppresses logging statements.
Nosy list
JonLevy, ced
Assigned to

Created on 2021-08-05.20:40:14 by JonLevy, last changed 2 months ago by JonLevy.


Author: [hidden] (JonLevy)
Date: 2021-08-06.15:32:12

In my experiment, yes disable_existing_loggers=True causes the existing logger to receive the configuration. I.e., setting level=WARN in the config file silences the INFO messages coming from modules/[1]

[1] My test was with python 2.7, in a migration to Tryton 4.0, but I expect that this behavior is the same in python 3.x.

Author: [hidden] (ced) Tryton committer Tryton translator
Date: 2021-08-06.14:19:07

If disable_existing_loggers=True is set, does existing logger receive the configuration? In your example if the configuration file disable INFO level, is it disabled?

Author: [hidden] (JonLevy)
Date: 2021-08-06.14:06:26

I should have been more clear. I am talking about the logger in modules/ What I experienced is that, when using a logging configuration file, I did not get the INFO log statements from this logger. Upon debugging, I found that logger.disabled == True, so it made no statements. I expect that you can easily reproduce this behavior by comparing the log statements you get from running a database update with a configuration file versus without. When passing a configuration file, you will see fewer log statements.

The reason this happens is that the default behavior of logging.config.fileConfig is to disabled any loggers that already exist before that function is called.[1] This can be corrected either by passing disable_existing_loggers=True, or by changing the order so that the logger is created after the fileConfig is applied.


Author: [hidden] (ced) Tryton committer Tryton translator
Date: 2021-08-05.23:38:19

I'm not sure to understand. Which file are you talking about? Nor why should it be ignored by the configuration set by fileConfig?

Author: [hidden] (JonLevy)
Date: 2021-08-05.20:50:18
Author: [hidden] (JonLevy)
Date: 2021-08-05.20:40:14 provides useful logging statement during database update. However, these are suppressed when using a logging config file. This happens because the logger instance in is created before the logging config file is applied in, and the default behavior of logging.config.fileConfig is to disable existing loggers.

This can be corrected by passing disable_existing_loggers=False to logging.config.fileConfig.[1]

Date User Action Args
2021-08-06 15:32:12JonLevysetmessages: + msg69227
2021-08-06 14:19:07cedsetmessages: + msg69223
2021-08-06 14:06:26JonLevysetmessages: + msg69221
2021-08-05 23:38:19cedsetmessages: + msg69170
nosy: + ced
2021-08-05 23:37:17cedsetassignedto: JonLevy
keyword: + review
reviews: 358551002
type: behavior
2021-08-05 20:50:18JonLevysetmessages: + msg69168
status: unread -> testing
2021-08-05 20:40:14JonLevycreate