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: logging package failure for NTEventLogHandler
Type: Stage:
Components: Library (Lib) Versions: Python 2.4
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: vinay.sajip Nosy List: jvickroy, nnorwitz, vinay.sajip
Priority: normal Keywords:

Created on 2007-03-22 17:00 by jvickroy, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
logging-configFile.zip jvickroy, 2007-03-22 17:00 a demo script and 2 initialization files for use with it
Messages (3)
msg31621 - (view) Author: j vickroy (jvickroy) Date: 2007-03-22 17:00
When using a configuration file to initialize a logger, a failure occurs in the logging.config.fileConfig() procedure such that the NTEventLogHandler is not created.

The failure is not observed when the NTEventLogHandler is explicitly defined in a script.

The attached script and two configuration initialization files demonstrate the failure as seen on a Microsoft Windows XP Pro computer running service pack 2 and Python 2.4.4 (#71, Oct 18 2006, 08:34:43) [MSC v.1310 32 bit (Intel)].

DETAILED DESCRIPTION:

   When the attached script is run with EventLog.ini, on my Windows XP computer, 
   the failure appears to occur at line 118:
      h = apply(klass, args)
   in File "C:\Python24\lib\logging\config.py" because for:
      klass: logging.handlers.NTEventLogHandler
   local variable *args* is:
      ('logging.config.fileConfig bug test')
   after line 116:
      args = cp.get(sectname, "args")
   but local variable *args* is:
      logging.config.fileConfig bug test
   after line 117:
      args = eval(args, vars(logging))
   
   The behavior for the other two handlers is as follows:

      klass = logging.StreamHandler
         args is: (sys.stdout,)                                       ... after line 116
         args is: (<open file '<stdout>', mode 'w' at 0x00A1E068>,)   ... after line 117

      klass = logging.handlers.TimedRotatingFileHandler
         args is: ('fileConfig-test.log', 'midnight', 1, 3)           ... after line 116
         args is: ('fileConfig-test.log', 'midnight', 1, 3)           ... after line 117
msg31622 - (view) Author: Neal Norwitz (nnorwitz) * (Python committer) Date: 2007-03-23 05:19
Vinay, any ideas?
msg31623 - (view) Author: Vinay Sajip (vinay.sajip) * (Python committer) Date: 2007-03-23 07:56
The problem is that the args line in the config file should evaluate to a tuple. You have, in EventLog.ini, the line

args=('logging.config.fileConfig bug test')

Which does not evaluate a tuple. If you add a trailing comma,

args=('logging.config.fileConfig bug test',)

then everything is fine. It's an easy mistake to make ;-)
History
Date User Action Args
2022-04-11 14:56:23adminsetgithub: 44761
2007-03-22 17:00:09jvickroycreate