# Log Organization and Management This document describes the log organization structure and management procedures for the MEV Bot. ## Log Directory Structure ``` logs/ ├── app/ # Application logs │ ├── mev_bot.log # Main application log │ ├── mev_bot_errors.log # Error-specific log │ └── mev_bot_performance.log # Performance metrics log ├── transactions/ # Transaction-related logs │ ├── mev_bot_transactions.log # Transaction execution logs │ └── mev_bot_opportunities.log # Arbitrage opportunities log ├── events/ # Event processing logs │ ├── liquidity_events_*.jsonl # Liquidity events (rotated) │ └── swap_events_*.jsonl # Swap events (rotated) ├── archived/ # Archived/compressed logs │ └── *.gz # Compressed old logs └── monitoring/ # Monitoring and metrics └── metrics_*.log # Periodic metrics logs ``` ## Log Categories ### Application Logs Contains general application logging information, including startup, shutdown, and general operational messages. ### Transaction Logs Records all transaction-related activities, including executed trades and identified arbitrage opportunities. ### Event Logs Captures DEX event processing, including liquidity events and swap events. These logs are rotated when they reach a certain size. ### Archived Logs Contains compressed historical logs that are retained for a specified period. ### Monitoring Logs Stores periodic metrics and monitoring data. ## Log Rotation Log rotation is managed by the `scripts/rotate-logs.sh` script, which: 1. Compresses event logs when they exceed 100MB 2. Moves compressed logs to the archived directory 3. Removes archived logs older than 30 days ## Log Management Commands To manually rotate logs: ```bash ./scripts/rotate-logs.sh ``` To view recent application logs: ```bash tail -f logs/app/mev_bot.log ``` To view recent error logs: ```bash tail -f logs/app/mev_bot_errors.log ``` To view recent transaction logs: ```bash tail -f logs/transactions/mev_bot_transactions.log ``` ## Log Retention Policy - Event logs: Compressed and archived when exceeding 100MB - Archived logs: Retained for 30 days - All other logs: No automatic rotation (managed by application) ## Troubleshooting If you're experiencing issues with log management: 1. Check that the `scripts/rotate-logs.sh` script has execute permissions 2. Verify that the log directories exist and have proper write permissions 3. Check disk space availability 4. Review script output for error messages