Monitor log files in a directory and output new lines as they're appended in real-time.
bettertail DIRECTORY [GLOB]Arguments:
DIRECTORY- Directory to watch for log files (required)GLOB- File pattern to match (optional, default:**/*.log)
Examples:
# Watch all .log files in /var/log
bettertail /var/log
# Watch only application logs
bettertail /var/log "app-*.log"
# Watch all text files in current directory
bettertail . "**/*.txt"- Real-time monitoring - Detects and outputs new lines as they're written
- Pattern matching - Supports glob patterns for flexible file selection
- Recursive watching - Monitors subdirectories automatically
- Log rotation handling - Correctly handles truncated and rotated logs
- Clean output - Each line shows relative path and content
pip install bettertailOr with uv:
uv pip install bettertail- The script should be concerned with newly appended lines, not with files. Which means:
- Only new lines, appended to log files should be printed.
- If a file is moved or renamed, the existing lines in the file should not be be printed, since they are not new lines.
- If a file is deleted, then nothing should be printed.
- When the script is first run, it should print nothing. It should instead wait for new lines to be appended to the log files it's watching.
- If an empty file is created in the directory, then nothing should be printed.
- (Note: Obviously it will be helpful to see these file movements during testing, in debug/verbose mode, but normal operation is religious about lines, not files)
- Each line should for formatted this way: "${rel path to file from root dir}: ${line content}\n".