fix: unify docker compose logs and admin panel log viewer#29
Merged
Conversation
- setup_file_logging now adds a StreamHandler to root if none exists, so application logs from the api (uvicorn) container reach stdout and appear in `docker compose logs -f` - uvicorn's loggers (uvicorn, uvicorn.access, uvicorn.error) are rerouted through root (propagate=True, own StreamHandlers removed) so HTTP access and error logs also appear in the log file read by the admin panel - docker-compose.yml: LOG_FILE=/data/ideal_bot.log on the shared data volume so both bot and api containers write to the same file, giving the admin panel a unified view matching `docker compose logs -f`
f77eb86 to
cdbe6a6
Compare
ChanyaVRC
commented
May 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
問題
docker compose logs -fと管理画面のログビューアに差異があった。原因は3つ:apiコンテナに StreamHandler がない: uvicorn プロセスはbasicConfigを呼ばないため、ルートロガーに StreamHandler がなく、アプリケーションログ(ルートハンドラー等)が stdout に出ない →docker compose logs -fに見えないuvicorn,uvicorn.access,uvicorn.errorはpropagate=False+ 独自の StreamHandler のため、ルートロガーを経由せずファイルハンドラーに届かない → 管理画面に見えないlog_fileが共有ボリューム上のパスでない場合、botとapiコンテナがそれぞれ別ファイルに書くため、管理画面(apiコンテナのファイルを読む)にはbotのログが見えない修正
src/logging_setup.pyapiコンテナでも stdout に出るように)propagate=Trueに変更し、独自 StreamHandler を除去してルートロガー経由に統一docker-compose.ymlLOG_FILE: /data/ideal_bot.logを両サービスに追加dataボリュームは両コンテナで共有されているため、同一ファイルに書き込まれるbot+api両方のログを統合表示できるテスト
propagate=Trueになること