<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def log_init():
 """ Function that sets log levels and format strings. Checks for the OT_API_LOG_LEVEL environment variable otherwise defaults to DEBUG. """

    fallback_log_level = 'INFO'
    ot_log_level = hardware.config.log_level
    if ot_log_level not in logging._nameToLevel:
        log.info("OT Log Level {} not found. Defaulting to {}".format(
            ot_log_level, fallback_log_level))
        ot_log_level = fallback_log_level

    level_value = logging._nameToLevel[ot_log_level]

    serial_log_filename = CONFIG['serial_log_file']
    api_log_filename = CONFIG['api_log_file']

    logging_config = dict(
        version=1,
        formatters={
            'basic': {
                'format':
                '%(asctime)s %(name)s %(levelname)s [Line %(lineno)s] %(message)s'  # noqa: E501
            }
        },
        handlers={
            'debug': {
                'class': 'logging.StreamHandler',
                'formatter': 'basic',
                'level': level_value
            },
            'serial': {
                'class': 'logging.handlers.RotatingFileHandler',
                'formatter': 'basic',
                'filename': serial_log_filename,
                'maxBytes': 5000000,
                'level': logging.DEBUG,
                'backupCount': 3
            },
            'api': {
                'class': 'logging.handlers.RotatingFileHandler',
                'formatter': 'basic',
                'filename': api_log_filename,
                'maxBytes': 1000000,
                'level': logging.DEBUG,
                'backupCount': 5
            }

        },
        loggers={
            '__main__': {
                'handlers': ['debug', 'api'],
                'level': logging.INFO
            },
            'opentrons.server': {
                'handlers': ['debug', 'api'],
                'level': level_value
            },
            'opentrons.api': {
                'handlers': ['debug', 'api'],
                'level': level_value
            },
            'opentrons.instruments': {
                'handlers': ['debug', 'api'],
                'level': level_value
            },
            'opentrons.config': {
                'handlers': ['debug', 'api'],
                'level': level_value
            },
            'opentrons.drivers.smoothie_drivers.driver_3_0': {
                'handlers': ['debug', 'api'],
                'level': level_value
            },
            'opentrons.drivers.serial_communication': {
                'handlers': ['serial'],
                'level': logging.DEBUG
            },
            'opentrons.drivers.thermocycler.driver': {
                'handlers': ['serial'],
                'level': logging.DEBUG
            },
            'opentrons.protocol_api': {
                'handlers': ['api', 'debug'],
                'level': level_value
            },
            'opentrons.hardware_control': {
                'handlers': ['api', 'debug'],
                'level': level_value
            },
            'opentrons.legacy_api.containers': {
                'handlers': ['api'],
                'level': level_value
            }
        }
    )
    dictConfig(logging_config)