This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Error reporting by logging.config.fileConfig()
Type: enhancement Stage:
Components: Extension Modules Versions: Python 2.6
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: mike, r.david.murray, vinay.sajip
Priority: low Keywords:

Created on 2009-07-02 09:50 by mike, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (8)
msg90007 - (view) Author: Mike (mike) Date: 2009-07-02 09:50
Hi,
I had a logging.conf file with the following logger def in it:

[logger_Builder]
level=DEBUG
handlers=consoleStderr
qualname=Builder
propogate=0

And I couldn't understand why all my log messages were coming out twice.
 It took me four hours :-\ to realise I had misspelt "propagate".

Wouldn't it be better if spurious names raised parsing exceptions?

Thanks,
Mike.

P.S. Another thing that might have helped me track this down a little
quicker is if I could have printed the name of the logger that was the
source of some output. %(name)s gives the logger that *received* the log
message.  If there was another format variable for the logger that was
the source of a log message I would have seen one message from Builder
and one message from root and it would have been more obvious what was
going on.
msg90036 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2009-07-02 23:10
Ignoring unknown options in the configuration file is analogous to
ignoring unknown tags in html: it makes it easier to use the same config
file with multiple versions of the logger, with older versions ignoring
the options they don't understand.  This is a tradeoff, and I suppose it
could be argued that the tradeoff is being made in the wrong direction
here.  I don't use configuration files for logging myself, so I'm not a
good person to render an opinion on that.

But IMO this is not a bug; changing the behavior would be a feature request.
msg90044 - (view) Author: Mike (mike) Date: 2009-07-03 07:50
Fair point.  Agree that this is a feature request.  Perhaps something like:

logging.config.fileConfig(path, strict=False)
msg90068 - (view) Author: Vinay Sajip (vinay.sajip) * (Python committer) Date: 2009-07-03 17:05
I'm not sure that this is a valid feature request. As R. David Murray
has said, it's sort of an unwritten rule of ConfigParser-based
applications that they look for specific entries, but don't care what
else is there in the file - sort of in line with Postel's Law.

The appearance of multiple messages pretty much points to multiple
handlers handling the message; knowing the way the hierarchy works,
propagation should have been one of the first things to check (as I
assume you had added handlers both at and above [logger_Builder]. I know
hindsight is wonderful, and I'm sorry it took you 4 hours to find the
problem; but I'm not convinced by this that I need to put more error
checking into the fileConfig code.
msg90227 - (view) Author: Mike (mike) Date: 2009-07-07 11:20
Sorry, I only started learning Python a couple of weeks ago.  Didn't
know that there was a ConfigParser module.  So this would really be a
feature request of ConfigParser?

Interesting you should mention Postel's Law.  Being liberal about what
you accept from others doesn't mean ignoring non-conformance.  Jon
Postel was clear that although you endeavour to continue when
encountering non-conformance you should always report it, lest
non-conformance propogates (sic).

I can think of two ways ConfigParser could report these problems. 
Either you give it a callback function it can call as it encounters
problems, or, after you have parsed a file you can call another function
that gives a list of any problems encountered.

If ConfigParser had this functionality it would then be straightforward
for the logging.config.fileConfig module to send these warnings to the
root logger.
msg90235 - (view) Author: Vinay Sajip (vinay.sajip) * (Python committer) Date: 2009-07-07 13:15
Well, there are other systems around (e.g. ConfigObj) which will allow
you to validate against a schema, but it's not part of the core so
logging can't rely on it.

I'm not sure how much interest there'd be in adding this kind of
validation to ConfigParser, but you could always try working up a patch
and assigning it to whoever maintains ConfigParser, or contacting that
person beforehand to see if it's worth it, or posting on c.lpy with the
same objective.
msg90273 - (view) Author: Mike (mike) Date: 2009-07-08 16:47
Hi Vinay,
I will bow to your greater expertise on this and will let this go.
It looks like it will be far more easier and robust just to invent my
own logging config file format and read it myself.
Thanks for your help.
Mike.
msg90293 - (view) Author: Vinay Sajip (vinay.sajip) * (Python committer) Date: 2009-07-08 23:10
Mike,

That's just fine. Sorry if I appear unhelpful, but in the open source
world we mostly scratch our own itches. I believe I have a reasonable
record on accepting patches from the community (though I don't of course
accept everything), and I unfortunately don't have much time to spend on
this because of other, more pressing itches :-( 

Best of luck with it.
History
Date User Action Args
2022-04-11 14:56:50adminsetgithub: 50648
2009-07-08 23:10:28vinay.sajipsetmessages: + msg90293
2009-07-08 16:47:54mikesetstatus: open -> closed

messages: + msg90273
2009-07-07 13:15:22vinay.sajipsetmessages: + msg90235
2009-07-07 11:20:17mikesetstatus: pending -> open

messages: + msg90227
2009-07-03 17:05:06vinay.sajipsetstatus: open -> pending
resolution: not a bug
messages: + msg90068
2009-07-03 07:50:22mikesetmessages: + msg90044
2009-07-02 23:10:54r.david.murraysetpriority: low

nosy: + vinay.sajip, r.david.murray
messages: + msg90036

type: behavior -> enhancement
2009-07-02 09:50:30mikecreate