Need help in configuration for TimedRotatingFileHandler

Lokesh Maremalla lokeshmaremalla at gmail.com
Mon Aug 10 01:07:37 EDT 2009


Hi Dave,

I have modified the code as mentioned in reply and is working fine. But
still i am facing an issue and the issue is described below.

In configuration file i have coded the TimedRotatingFileHandler like
args=("G:\\lok_sib\\logs\\rotate_test", 'D', 1)

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

Thanks for your time.

Regards,
Lokesh


On Mon, Aug 10, 2009 at 2:45 AM, Dave Angel <davea at ieee.org> wrote:

> Lokesh wrote:
>
>> Hi,
>>
>> Need help in configure the TimedRotatingFileHandler from configuration
>> file
>>
>> I have tried with the below code and ended up with the error, code is
>> pasted below
>> Error - IOError: [Errno 2] No such file or directory: 'G:\\lok_sib\
>> \logs\rotate_test'
>> [loggers]
>> keys=root,simpleExample
>>
>> [handlers]
>> keys=consoleHandler,timedRotatingFileHandler
>>
>> [formatters]
>> keys=simpleFormatter
>>
>> [logger_root]
>> level=DEBUG
>> handlers=consoleHandler
>>
>> [logger_simpleExample]
>> level=DEBUG
>> handlers=timedRotatingFileHandler
>> qualname=simpleExample
>> propagate=0
>>
>> [handler_consoleHandler]
>> class=StreamHandler
>> level=DEBUG
>> formatter=simpleFormatter
>> args=(sys.stdout,)
>>
>> [handler_timedRotatingFileHandler]
>> class=handlers.TimedRotatingFileHandler
>> level=DEBUG
>> formatter=simpleFormatter
>> args=("G:\lok_sib\logs\rotate_test", 'midnight', 1)
>>
>> [formatter_simpleFormatter]
>> format=%(asctime)s - %(name)s - %(levelname)s - %(message)s
>> datefmt='%Y-%m-%d %H:%M:%S'
>>
>>
>> Thanks or your time
>> Regards,
>> Lokesh
>>
>>
>>
> I don't see code there, I see lots of config data, presumably in an .ini
> file.   So I don't know how you're reading it in, and converting it to
> Python variables, but I know where I'd look, based on your error message.
>
> The following line:
>
> args=("G:\lok_sib\logs\rotate_test", 'midnight', 1)
>
> seems to contain a Python string.  But there are unescaped backslashes
> within it.  You can get away with it in two cases, because \l  isn't a valid
> escape sequence.  But in the case of \r, it looks like a newline character.
>
> Anyway, all three of those backslashes probably need to be doubled.
>
> args=("G:\\lok_sib\\logs\\rotate_test", 'midnight', 1)
>
> Two other cures that may work, depending on context:   change the
> backslashes to forward slashes, or use a raw string.
>
> But as I said earlier, you don't show in any way what code is interpreting
> this line, so it's all just guesswork.
>
> DaveA
>
>


-- 
Thanks & Regards,
Lokesh.
lokeshmaremalla at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20090810/44b4a0d3/attachment.html>


More information about the Python-list mailing list