Lokesh Maremalla wrote:
<snip>
Code:
mlogger = logging.getLogger("simpleExample")
def a_view(request):
mlogger.debug("a_view called")
if request.method== "POST" :
mlogger.debug("post function")
else:
mlogger.debug("serve function")
Execution:
step1: Executed the code and got the log file with the information
step2: Modified the system time from current day to next day
step3: End up with the error and the error is pasted below
Traceback (most recent call last):
File "c:\Python25\lib\logging\handlers.py", line 74, in emit
self.doRollover()
File "c:\Python25\lib\logging\handlers.py", line 274, in doRollover
os.rename(self.baseFilename, dfn)
WindowsError: [Error 32] The process cannot access the file because it is
being used by another process
Python version - 2.5.4
I guess my output should be like this for the next day
-a new log file rotate_test.<date format> should generate in the respective
location
Please correct me if I am wrong.
Thanks for your time.
Regards,
Lokesh
Generally speaking, this error on os.rename() will occur if you haven't
properly closed the file first, and if I recall correctly, Unix would
have permitted a rename on an open file. You're on Windows. However, I
don't know how that works with the logging package. If the program has
terminated, and you run it a second time on the following day (or after
changing the system time), then I'd expect no trouble. But I'm guessing
your program is still running, and you just want to change from logging
to yesterday's file to logging to today's file.
If I had to guess, I'd say that you have two instances of the logger
running, and the second one is still holding the handle open. But
that's just a wild guess.
Could someone else who is familiar with logging, and with
TimedRotatingFileHandler in particular, jump in here? Preferably a
Windows person?
DaveA
--
http://mail.python.org/mailman/listinfo/python-list