Logging

Discussion in 'Python' started by Neil Benn, Feb 2, 2005.

  1. Neil Benn

    Neil Benn Guest

    Hello,

    I'm running a test and having issues with logging, if I call
    logging.shutdown() and then want to start the logging going again then I
    get a problem as if I call shutdown, I can't get the root logger again,
    such as :

    ..>>> import logging
    ..>>> objTestLogger = logging.getLogger()
    ..>>> objTestLogger.setLevel(logging.INFO)
    ..>>> objTestLogger.addHandler(logging.FileHandler('c:\\test.log'))
    ..>>> objTestLogger.info("THIS IS A TEST")
    ..>>> logging.shutdown()
    ..>>> objTestLogger = logging.getLogger()
    ..>>> objTestLogger.setLevel(logging.INFO)
    ..>>> objTestLogger.info("THIS IS A TEST")
    ..Traceback (most recent call last):
    .. File "<stdin>", line 1, in ?
    .. File "c:\program files\python23\lib\logging\__init__.py", line 893,
    in info
    .. apply(self._log, (INFO, msg, args), kwargs)
    .. File "c:\program files\python23\lib\logging\__init__.py", line 994,
    in _log
    .. self.handle(record)
    .. File "c:\program files\python23\lib\logging\__init__.py", line 1004,
    in handle
    .. self.callHandlers(record)
    .. File "c:\program files\python23\lib\logging\__init__.py", line 1037,
    in callHandlers
    .. hdlr.handle(record)
    .. File "c:\program files\python23\lib\logging\__init__.py", line 592,
    in handle
    .. self.emit(record)
    .. File "c:\program files\python23\lib\logging\handlers.py", line 103,
    in emit
    .. self.stream.seek(0, 2) #due to non-posix-compliant Windows feature
    ..ValueError: I/O operation on closed file
    ..>>>

    This means that I any code that write or use, if it calls
    logging.shutdown the logging is buggered for that process - is my
    analysis correct?

    Cheers,

    Neil

    --

    Neil Benn
    Senior Automation Engineer
    Cenix BioScience
    BioInnovations Zentrum
    Tatzberg 46
    D-01307
    Dresden
    Germany

    Tel : +49 (0)351 4173 154
    e-mail :
    Cenix Website : http://www.cenix-bioscience.com
    Neil Benn, Feb 2, 2005
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Stefan Siegl
    Replies:
    0
    Views:
    940
    Stefan Siegl
    Aug 27, 2003
  2. janne
    Replies:
    0
    Views:
    9,445
    janne
    Sep 10, 2004
  3. Christoph Haas
    Replies:
    0
    Views:
    431
    Christoph Haas
    Jun 12, 2006
  4. Christoph Haas
    Replies:
    1
    Views:
    441
    Vinay Sajip
    Jun 14, 2006
  5. johnny
    Replies:
    1
    Views:
    621
    Dennis Lee Bieber
    Dec 12, 2006
Loading...

Share This Page