1

I have already tried the RotatingFileHandler, That solution is not what I am looking for. I want a system that will automatically split log file into multiple files if it exceeds a certain limit (ex 10MB).

Already tried this, but this is not what I want.

my_handler = RotatingFileHandler(log_filename, mode='a', maxBytes=1024*1024*10, backupCount=2, encoding=None, delay=0)

Actually Rotating file handler has a rollover thing, which makes the logs neverending but not unlimited. What I mean to say, if my logs cross a certain limit (both files and size), the logs which were taken in the beginning get omitted/deleted.

I know I can simply increase the file size and backup number, but again there is a limit. Which I do not want.

vvvvv
  • 25,404
  • 19
  • 49
  • 81
koshur
  • 124
  • 1
  • 9
  • 4
    Why is it not what you want? https://stackoverflow.com/questions/40088496/how-to-use-pythons-rotatingfilehandler – Passerby Nov 28 '21 at 14:01
  • This might be interesting too: https://stackoverflow.com/questions/48095578/why-does-python-rotatingfilehandlers-maxbytes-not-work/48095853 – Szala Nov 28 '21 at 14:12
  • 1
    Actually Rotating file handler has a rollover thing, which makes the logs neverending but not unlimited. What I mean to say, if my logs cross a certain limit (both files and size), the logs which were taken in the beginning get omitted/deleted. – koshur Nov 28 '21 at 14:22
  • This is the reason why I want a simple system that takes a neverending and unlimited amount of logs, it should simply split the log file into multiple files if it exceeds a certain limit. – koshur Nov 28 '21 at 14:24
  • Why can't you subclass RotatingFileHandler and add the behaviour changes in your subclass? – Vinay Sajip Nov 28 '21 at 15:58
  • Got a solution that splits the file but do not rotate them? – Welsige Dec 02 '22 at 16:33

0 Answers0