[ python-Bugs-1508253 ] logging fileConfig swallows handler exception
SourceForge.net
noreply at sourceforge.net
Thu Jun 22 18:37:20 CEST 2006
Bugs item #1508253, was opened at 2006-06-18 19:33
Message generated for change (Comment added) made by vsajip
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1508253&group_id=5470
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Library
Group: Python 2.4
Status: Open
>Resolution: Works For Me
Priority: 5
Submitted By: tdir (tdir)
Assigned to: Vinay Sajip (vsajip)
Summary: logging fileConfig swallows handler exception
Initial Comment:
If you specify a handler such as a RotatingFileHandler
and the path you provide in the args specification
('option') is bad, config.fileConfig() catches the
exception and 'swallows' it. The result is later on,
when that handler is specified for a logger, you get an
exception saying there is no such handler. A much
friendlier behavior would be for fileConfig() to raise
an exception so the real cause of the problem can be
easily identified. Also, if there is a bug in the code
itself, it would also get swallowed in similar fashion.
In general, silently swallowing exceptions is rarely
the best choice IMHO.
Example ini with bad path (assuming /bad/path does not
exist):
[handler_defaultrotatingfile]
class=handlers.RotatingFileHandler
args=("/bad/path/logdir/my_log.log", 'w', 100000, 10)
formatter=std
----------------------------------------------------------------------
>Comment By: Vinay Sajip (vsajip)
Date: 2006-06-22 16:37
Message:
Logged In: YES
user_id=308438
Can you give some more details? I don't get the problem: see
the transcript below.
ActivePython 2.4 Build 243 (ActiveState Corp.) based on
Python 2.4 (#60, Nov 30 2004, 09:34:21) [MSC v.1310 32 bit
(Intel)] on win32
Type "help", "copyright", "credits" or "license" for more
information.
>>> import logging.config
>>> logging.config.fileConfig("junk.ini")
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "C:\Python\lib\logging\config.py", line 83, in fileConfig
handlers = _install_handlers(cp, formatters)
File "C:\Python\lib\logging\config.py", line 151, in
_install_handlers
h = apply(klass, args)
File "C:\Python\lib\logging\handlers.py", line 109, in
__init__
BaseRotatingHandler.__init__(self, filename, mode, encoding)
File "C:\Python\lib\logging\handlers.py", line 61, in __init__
logging.FileHandler.__init__(self, filename, mode, encoding)
File "C:\Python\lib\logging\__init__.py", line 770, in
__init__
stream = open(filename, mode)
IOError: [Errno 2] No such file or directory:
'/bad/path/junk.log'
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1508253&group_id=5470
More information about the Python-bugs-list
mailing list