M
M
MaBa20142021-03-18 10:42:45
Python
MaBa2014, 2021-03-18 10:42:45

How to fix error when rotating log file?

Good afternoon, tell me how to fix the error?
PermissionError: [WinError 32] The process cannot access the file because the file is in use by another process:
'C:\\Users\\User\\PycharmProjects\\Proj1\\app\\app.log' -> 'C :\\Users\\User\\PycharmProjects\\proj1\\app\\app.log.1'

logging.basicConfig(filename='app.log') # Create a log file # Rotate

next
logger = logging.getLogger( "Log")

handler = RotatingFileHandler("app.log", maxBytes=200, backupCount=2)
logger.setLevel(logging.INFO)
logger.addHandler(handler)
... #Next
in the code I call
logger.warning("Successful authorization attempt)


With all this, the files are written to the logs, but when overflowed, they do not recreate a new file and give an error with each recording

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question