Author jacuro
Recipients jacuro
Date 2012-05-25.02:19:38
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1337912379.85.0.584273983424.issue14906@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2012-05-25 02:19:39jacurosetrecipients: + jacuro
2012-05-25 02:19:39jacurosetmessageid: <1337912379.85.0.584273983424.issue14906@psf.upfronthosting.co.za>
2012-05-25 02:19:39jacurolinkissue14906 messages
2012-05-25 02:19:38jacurocreate