Also the `$logger` should be created only when this `if` is matched.