# Logging and Monitoring Tools This document explains how to use the logging and monitoring tools in this project for effective development and troubleshooting. ## Log File Specification When running the application, you can specify a custom log file name using the `--log-file` parameter: ``` python train_rl_with_realtime.py --episodes 1 --no-train --visualize-only --log-file custom_log_name.log ``` This makes it easier to identify specific log files for particular runs during development. ## Log Reader Utility The `read_logs.py` script provides a convenient way to read and filter log files: ### List all log files To see all available log files sorted by modification time: ``` python read_logs.py --list ``` ### Read a specific log file To read the last 50 lines of a specific log file: ``` python read_logs.py --file your_log_file.log ``` If you don't specify a file, it will use the most recently modified log file. ### Filter log content To only show lines containing specific text: ``` python read_logs.py --file your_log_file.log --filter "trade" ``` ### Follow log updates in real-time To monitor a log file as it grows (similar to `tail -f` in Unix): ``` python read_logs.py --file your_log_file.log --follow ``` You can also combine filtering with following: ``` python read_logs.py --file your_log_file.log --filter "ERROR" --follow ``` ## Startup Scripts ### Windows Batch Script The `start_app.bat` script starts the application with log monitoring in separate windows: ``` start_app.bat ``` This will: 1. Start the application with a timestamped log file 2. Open a log monitoring window 3. Open the dashboard in your default browser ### PowerShell Script The `StartApp.ps1` script offers a more advanced monitoring experience: ``` .\StartApp.ps1 ``` This will: 1. Start the application in the background 2. Open the dashboard in your default browser 3. Show log output in the current window with colored formatting 4. Provide instructions for managing the background application job ## Common Log Monitoring Patterns ### Monitor for errors ``` python read_logs.py --filter "ERROR|Error|error" --follow ``` ### Watch trading activity ``` python read_logs.py --filter "trade|position|BUY|SELL" --follow ``` ### Monitor performance metrics ``` python read_logs.py --filter "reward|balance|PnL|win rate" --follow ```