Hi Dave,<br><br>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.<br><br>In configuration file i have coded the TimedRotatingFileHandler like <br>args=("G:\\lok_sib\\logs\\rotate_test", 'D', 1)<br><br>step1: Executed the code and got the log file with the information<br>
step2: Modified the system time from current day to next day<br>step3: End up with the error and the error is pasted below<br>
<br>Traceback (most recent call last):<br> File "c:\Python25\lib\logging\handlers.py", line 74, in emit<br> self.doRollover()<br> File "c:\Python25\lib\logging\handlers.py", line 274, in doRollover<br>
os.rename(self.baseFilename, dfn)<br>WindowsError: [Error 32] The process cannot access the file because it is being used by another process<br><br>Python version - 2.5.4<br><br>Thanks for your time.<br><br>Regards,<br>
Lokesh<br><br><br><div class="gmail_quote">On Mon, Aug 10, 2009 at 2:45 AM, Dave Angel <span dir="ltr"><<a href="mailto:davea@ieee.org">davea@ieee.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div><div></div><div class="h5">Lokesh wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi,<br>
<br>
Need help in configure the TimedRotatingFileHandler from configuration<br>
file<br>
<br>
I have tried with the below code and ended up with the error, code is<br>
pasted below<br>
Error - IOError: [Errno 2] No such file or directory: 'G:\\lok_sib\<br>
\logs\rotate_test'<br>
[loggers]<br>
keys=root,simpleExample<br>
<br>
[handlers]<br>
keys=consoleHandler,timedRotatingFileHandler<br>
<br>
[formatters]<br>
keys=simpleFormatter<br>
<br>
[logger_root]<br>
level=DEBUG<br>
handlers=consoleHandler<br>
<br>
[logger_simpleExample]<br>
level=DEBUG<br>
handlers=timedRotatingFileHandler<br>
qualname=simpleExample<br>
propagate=0<br>
<br>
[handler_consoleHandler]<br>
class=StreamHandler<br>
level=DEBUG<br>
formatter=simpleFormatter<br>
args=(sys.stdout,)<br>
<br>
[handler_timedRotatingFileHandler]<br>
class=handlers.TimedRotatingFileHandler<br>
level=DEBUG<br>
formatter=simpleFormatter<br>
args=("G:\lok_sib\logs\rotate_test", 'midnight', 1)<br>
<br>
[formatter_simpleFormatter]<br>
format=%(asctime)s - %(name)s - %(levelname)s - %(message)s<br>
datefmt='%Y-%m-%d %H:%M:%S'<br>
<br>
<br>
Thanks or your time<br>
Regards,<br>
Lokesh<br>
<br>
<br>
</blockquote></div></div>
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.<br>
<br>
The following line:<div class="im"><br>
<br>
args=("G:\lok_sib\logs\rotate_test", 'midnight', 1)<br>
<br></div>
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.<br>
<br>
Anyway, all three of those backslashes probably need to be doubled.<div class="im"><br>
<br>
args=("G:\\lok_sib\\logs\\rotate_test", 'midnight', 1)<br>
<br></div>
Two other cures that may work, depending on context: change the backslashes to forward slashes, or use a raw string.<br>
<br>
But as I said earlier, you don't show in any way what code is interpreting this line, so it's all just guesswork.<br>
<br>
DaveA<br>
<br>
</blockquote></div><br><br clear="all"><br>-- <br>Thanks & Regards,<br>Lokesh.<br><a href="mailto:lokeshmaremalla@gmail.com">lokeshmaremalla@gmail.com</a><br>