import logging
import logging.handlers
import os
dirname = os.path.dirname(__file__)

LOG_FILENAME = filename = os.path.join(dirname, '../log/wso2carbon.log')
logger = logging.getLogger()

def set_logger():
    logger.setLevel(logging.INFO)
    formatter = logging.Formatter('%(asctime)s %(levelname)s: %(message)s')

    console_handler = logging.StreamHandler()
    console_handler.setFormatter(formatter)
    logger.addHandler(console_handler)

    file_handler = logging.handlers.RotatingFileHandler(
        LOG_FILENAME, maxBytes=10485760, backupCount=10, encoding="utf-8")
    file_handler.setFormatter(formatter)
    logger.addHandler(file_handler)

set_logger()
import logging
import logging.handlers
import os
dirname = os.path.dirname(__file__)

LOG_FILENAME = filename = os.path.join(dirname, '../log/wso2carbon.log')
logger = logging.getLogger()

def set_logger():
    logger.setLevel(logging.INFO)
    formatter = logging.Formatter('%(asctime)s %(levelname)s: %(message)s')

    console_handler = logging.StreamHandler()
    console_handler.setFormatter(formatter)
    logger.addHandler(console_handler)

    file_handler = logging.handlers.TimedRotatingFileHandler(LOG_FILENAME, when='midnight', backupCount=30)
    #Uncomment the below file_handler for a size based Rotating File handler.
    #file_handler = logging.handlers.RotatingFileHandler(LOG_FILENAME,maxBytes=10485760,backupCount=10,encoding="utf-8")

    file_handler.setFormatter(formatter)
    logger.addHandler(file_handler)

set_logger()
Change log rotation to time base rotation from size based rotation