Hi,
i'm getting errors with the log module concerning RotatingFileHan dler.
I'm using Python 2.4.3 on Windows XP SP2. This used to work in previous
python versions but since i upgraded to 2.4.3 i get these errors:
Traceback (most recent call last):
File "C:\Python24\li b\logging\handl ers.py", line 71, in emit
if self.shouldRoll over(record):
File "C:\Python24\li b\logging\handl ers.py", line 150, in shouldRollover
self.stream.see k(0, 2) #due to non-posix-compliant Windows feature
ValueError: I/O operation on closed file
2006-06-25 10:35:07,171 INFO firebird 210 Starting up the database
Traceback (most recent call last):
File "C:\Python24\li b\logging\handl ers.py", line 72, in emit
self.doRollover ()
File "C:\Python24\li b\logging\handl ers.py", line 134, in doRollover
self.handleErro r(record)
NameError: global name 'record' is not defined
I use the logging module by loading a config file:
import logging
import logging.config
LOGFILE = r"logconf.in i"
Then in the init function of the class
# load logger
logging.config. fileConfig(LOGF ILE)
self.log = logging.getLogg er('stats')
If i have a main class and a class deriving from it, i let the main
class instantiate the class by issueing the commands like above and then
get automatically get access to it in the deriving classes.
If i remove the logfile, it all works until it has to rollover.
My config.ini file contains this info:
[loggers]
keys=root,stats ,database
[handlers]
keys=hand01,han d02
[formatters]
keys=form01,for m02
[logger_root]
level=NOTSET
handlers=hand01
qualname=(root) # note - this is used in non-root loggers
propagate=1 # note - this is used in non-root loggers
channel=
parent=
[logger_stats]
level=DEBUG
propagate=0
qualname=stats
handlers=hand01 ,hand02
channel=log02
parent=(root)
[logger_database]
level=DEBUG
propagate=0
qualname=databa se
handlers=hand01 ,hand02
channel=log03
parent=(root2
[handler_hand01]
class=StreamHan dler
level=DEBUG
formatter=form0 1
args=(sys.stdou t,)
stream=sys.stdo ut
[handler_hand02]
class=handlers. RotatingFileHan dler
level=NOTSET
formatter=form0 1
filename=stats. log
mode=a
maxsize=500000
backcount=9
args=('stats.lo g', 'a', 900000, 5)
[formatter_form0 1]
format=%(asctim e)s %(levelname)s %(module)s %(lineno)d %(message)s
datefmt=
[formatter_form0 2]
format=%(asctim e)s %(levelname)s %(module)s %(lineno)d %(message)s
datefmt=
Any idea on why this suddenly doesn't work anymore?
Thanks
i'm getting errors with the log module concerning RotatingFileHan dler.
I'm using Python 2.4.3 on Windows XP SP2. This used to work in previous
python versions but since i upgraded to 2.4.3 i get these errors:
Traceback (most recent call last):
File "C:\Python24\li b\logging\handl ers.py", line 71, in emit
if self.shouldRoll over(record):
File "C:\Python24\li b\logging\handl ers.py", line 150, in shouldRollover
self.stream.see k(0, 2) #due to non-posix-compliant Windows feature
ValueError: I/O operation on closed file
2006-06-25 10:35:07,171 INFO firebird 210 Starting up the database
Traceback (most recent call last):
File "C:\Python24\li b\logging\handl ers.py", line 72, in emit
self.doRollover ()
File "C:\Python24\li b\logging\handl ers.py", line 134, in doRollover
self.handleErro r(record)
NameError: global name 'record' is not defined
I use the logging module by loading a config file:
import logging
import logging.config
LOGFILE = r"logconf.in i"
Then in the init function of the class
# load logger
logging.config. fileConfig(LOGF ILE)
self.log = logging.getLogg er('stats')
If i have a main class and a class deriving from it, i let the main
class instantiate the class by issueing the commands like above and then
get automatically get access to it in the deriving classes.
If i remove the logfile, it all works until it has to rollover.
My config.ini file contains this info:
[loggers]
keys=root,stats ,database
[handlers]
keys=hand01,han d02
[formatters]
keys=form01,for m02
[logger_root]
level=NOTSET
handlers=hand01
qualname=(root) # note - this is used in non-root loggers
propagate=1 # note - this is used in non-root loggers
channel=
parent=
[logger_stats]
level=DEBUG
propagate=0
qualname=stats
handlers=hand01 ,hand02
channel=log02
parent=(root)
[logger_database]
level=DEBUG
propagate=0
qualname=databa se
handlers=hand01 ,hand02
channel=log03
parent=(root2
[handler_hand01]
class=StreamHan dler
level=DEBUG
formatter=form0 1
args=(sys.stdou t,)
stream=sys.stdo ut
[handler_hand02]
class=handlers. RotatingFileHan dler
level=NOTSET
formatter=form0 1
filename=stats. log
mode=a
maxsize=500000
backcount=9
args=('stats.lo g', 'a', 900000, 5)
[formatter_form0 1]
format=%(asctim e)s %(levelname)s %(module)s %(lineno)d %(message)s
datefmt=
[formatter_form0 2]
format=%(asctim e)s %(levelname)s %(module)s %(lineno)d %(message)s
datefmt=
Any idea on why this suddenly doesn't work anymore?
Thanks
Comment