modify logers.py remove and rename part

I found this part is repeated: 

```
if os.path.exists(dfn):
    try:
          os.remove(dfn)
    except OSError, why:
          # catch race condition (already deleted)
          if why.args[0] != errno.ENOENT:
               raise
os.rename(sfn, dfn)
```