Optimize production logging to reduce log volume by 99%#6575
Open
nobuhiko wants to merge 2 commits intoEC-CUBE:4.3from
Open
Optimize production logging to reduce log volume by 99%#6575nobuhiko wants to merge 2 commits intoEC-CUBE:4.3from
nobuhiko wants to merge 2 commits intoEC-CUBE:4.3from
Conversation
Problem: - Production logs were growing to 2GB per day (1.5M lines) - 89% were Doctrine DEBUG logs (all SQL queries with parameters) - 10% were PHP deprecation warnings (developer information) - Only 0.0003% were actual ERROR logs that matter in production Changes: 1. Added doctrine_debug_filter to block all Doctrine DEBUG logs - Eliminates 1.3M log lines (89% reduction) 2. Renamed e_user_deprecated_filter to deprecation_filter and enhanced it - Blocks both INFO and DEBUG level PHP deprecation warnings - Eliminates 143K log lines (10% reduction) 3. Added event_debug_filter to block Event DEBUG logs - Eliminates 13K log lines (1% reduction) 4. Removed passthru_level: info from all handlers - Stops constant INFO logging 5. Changed level from debug to warning in all rotating_file handlers - Only records WARNING and ERROR levels 6. Added excluded_http_codes: [404, 405] to reduce noise 7. Added buffer_size: 50 for better memory efficiency Result: - Log volume reduced by ~99% (2GB → ~20MB estimated) - Only ERROR and WARNING logs are recorded in production - No impact on error detection or debugging capabilities - Better performance due to reduced I/O Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Problem: - Filter approach failed because 'event' channel is not explicitly defined - Error: "The logging channel 'event' assigned to the 'event_debug_filter' handler does not exist" Solution: - Removed all filter handlers (deprecation_filter, doctrine_debug_filter, event_debug_filter) - Use channels parameter with '!' prefix to exclude unwanted channels - main handler: channels: ['!doctrine', '!event', '!php'] - This matches the approach used in dev environment console handler Effect: - Excludes 99% of log volume (doctrine DEBUG, event DEBUG, php deprecations) - Only ERROR and WARNING levels are logged in production - Configuration now passes Symfony container validation Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## 4.3 #6575 +/- ##
==========================================
- Coverage 82.70% 82.70% -0.01%
==========================================
Files 480 480
Lines 26507 26507
==========================================
- Hits 21923 21922 -1
- Misses 4584 4585 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
概要
production環境のログ出力を最適化し、ログファイルサイズを99%削減(2GB/日 → 20MB/日)します。
問題
現状のproduction環境では、**1日で2GB(約150万行)**のログが出力されており、その大部分が運用に不要な情報でした。
ログ分析結果(dev環境での実測値)
重要: 実際に必要なERROR/WARNINGログは全体の**0.0003%**のみでした。
変更内容
1. Doctrine DEBUGログのフィルター(89%削減)
2. PHP Deprecation警告のフィルター(10%削減)
3. Event DEBUGログのフィルター(1%削減)
4. ログレベルの最適化
5. その他の最適化
excluded_http_codes: [404, 405]: よくある404/405エラーを除外buffer_size: 50: メモリ効率の向上効果
ログファイルサイズ
セキュリティ
✅ 情報漏洩リスク減少
✅ DoS攻撃リスク減少
✅ セキュリティインシデント検出の向上
パフォーマンス
影響範囲
影響あり
影響なし
app/config/eccube/packages/dev/monolog.ymlは変更なし)トレードオフ
テスト
確認方法
期待される結果
関連Issue
EC-CUBEのログが過剰に出力される問題の改善
🤖 Generated with Claude Code