This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2012年05月25日 02:19 by jacuro, last changed 2022年04月11日 14:57 by admin. This issue is now closed.
| Messages (3) | |||
|---|---|---|---|
| msg161546 - (view) | Author: Curu Wong (jacuro) | Date: 2012年05月25日 02:19 | |
I setup and use rotatingHandler this way:
=========================================================
#create logger
logger = logging.getLogger(__name__)
logger.setLevel(logging.INFO)
#create rotate handler
rotatefh = logging.handlers.RotatingFileHandler(filename=logfile, maxBytes=20000000, backupCount=100)
rotatefh.setLevel(logging.INFO)
#create formatter
formatter = logging.Formatter('%(asctime)s %(levelname)s: %(message)s')
rotatefh.setFormatter(formatter)
logger.addHandler(rotatefh)
...
logger.info("%s, create time: %s" % (pdb, time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(create_time))))
logger.info("copying '%s' to '%s' ..." % (src, dst))
copy_cmd = 'xcopy /I /E /Y "%s" "%s"' % (src, dst)
process = subprocess.Popen(copy_cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
for msg in process.stdout:
logger.info(msg.strip())
process.wait()
error_msg = process.stderr.read()
if error_msg:
logger.error(error_msg.strip())
else:
if build_num in release_version:
logger.info("leave release version '%s' un touched" % pdb)
continue
else:
logger.info("deleting '%s'" % src)
subprocess.call('rd /s /q "%s"' % src, shell=True)
logger.info("=" * 80)
==========================================================
All other part has nothing to do with log file.
when it comes to rotate, I always get this error:
============================================================
Traceback (most recent call last):
File "C:\Python27\lib\logging\handlers.py", line 78, in emit
self.doRollover()
File "C:\Python27\lib\logging\handlers.py", line 141, in doRollover
os.rename(self.baseFilename, dfn)
WindowsError: [Error 32]
Logged from file backup_pdb.py, line 76
Traceback (most recent call last):
File "C:\Python27\lib\logging\handlers.py", line 78, in emit
self.doRollover()
File "C:\Python27\lib\logging\handlers.py", line 141, in doRollover
os.rename(self.baseFilename, dfn)
WindowsError: [Error 32]
Logged from file backup_pdb.py, line 76
Traceback (most recent call last):
File "C:\Python27\lib\logging\handlers.py", line 78, in emit
self.doRollover()
File "C:\Python27\lib\logging\handlers.py", line 141, in doRollover
os.rename(self.baseFilename, dfn)
WindowsError: [Error 32]
Logged from file backup_pdb.py, line 76
============================================================
I don't have any anti-virus software on this machine, the error is somewhat like http://bugs.python.org/issue14450 . However, I have only one handler referring to the log file, but still get the error.
|
|||
| msg162640 - (view) | Author: Vinay Sajip (vinay.sajip) * (Python committer) | Date: 2012年06月11日 19:50 | |
It could be a number of things which are keeping the file open, e.g. * Windows indexing the volume for search * Child process keeping files open (e.g. while copying log files - I can't tell what you're actually copying) You may need to use a tool like FileMon or PSMon to see what's happening, but I don't see any evidence that it's a logging bug. Is there a specific logging statement which is being called which leads to the error? There are several in your snippet. |
|||
| msg163757 - (view) | Author: Vinay Sajip (vinay.sajip) * (Python committer) | Date: 2012年06月24日 09:49 | |
Closed for lack of evidence, please re-open when and if more information is available. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:57:30 | admin | set | github: 59111 |
| 2012年06月24日 09:49:46 | vinay.sajip | set | status: open -> closed resolution: not a bug messages: + msg163757 |
| 2012年06月11日 19:50:34 | vinay.sajip | set | assignee: vinay.sajip messages: + msg162640 nosy: + vinay.sajip |
| 2012年05月25日 02:19:39 | jacuro | create | |