This script automates the analysis and monitoring of log files. It continuously monitors a specified log file for new entries and performs basic analysis on the log entries.
- Real-time monitoring of log files
- Keyword-based analysis of log entries
- Summary reports of keyword occurrences
- Graceful handling of interrupts and errors
- Python 3.x
- Clone the repository:
git clone https://github.com/Manazsharma/Log-analysis
-
Open a terminal and navigate to the directory containing the
log-monitor.py
file. -
Run the script using the following command:
python log-monitor.py
-
The script will start monitoring the specified log file and display new log entries in real-time.
-
Press
Ctrl+C
to stop the monitoring process.
- Modify the
process_log_entry
function to implement additional analysis logic based on your specific requirements. - Adjust the
keywords
list in theprocess_log_entry
function to include relevant keywords or patterns for your log analysis.
The script includes error handling for the following scenarios:
- Keyboard interrupts (e.g., pressing
Ctrl+C
) to stop the monitoring process - File not found errors if the specified log file does not exist
- General exceptions to catch and log any unexpected errors
- Error Message Counting: The script counts the occurrences of error messages in the log entries.
Contributions are welcome! If you find any issues or have suggestions for improvements, please open an issue or submit a pull request.