Fix logger for case Yii::$app lost on process exiting

`Logger::flush()` might be called by `register_shutdown_function()` when application instance has gone.

In fact, Codeception extension clears `Yii::$app` on every test cases.

https://github.com/yiisoft/yii2/blob/c9d51ee0fddec74a5c5da61c1eb933c7b3c8a49e/extensions/codeception/TestCase.php#L129