I want to create a logger that will work in the following way:
I want to limit the log file size to - X mb, and when the file is full, I want that it to continue putting new logs to end of file, but erasing the older logs from beginning of the file. Is this something possible to achieve?
I tried to use RotatingFileHandler
but it doesn't seem to work, because the file exceeded the max size.
Here is how I configured the handlers section in LOGGING dictionary, in my settigns file:
'handlers': {
'file': {
'level': 'DEBUG',
'class': 'logging.FileHandler',
'filename': '/home/ubuntu/logs/django.log',
},
'request_file_info': {
'level': 'INFO',
'class': 'logging.FileHandler',
'filename': '/home/ubuntu/logs/request_configuration.log',
'formatter': 'verbose'
},
},