There is another way of making this work. Export your middleware.js with the env object and pass it a default. This way you can make sure your process.env will override it:
module.exports = ({ env }) => ({
settings: {
logger: {
level: env('STRAPI_LOG_LEVEL', 'debug')
}
}
})