A Python script that parses log files, filters entries by timestamp, log level, or message content, and summarizes errors. Designed to demonstrate troubleshooting and log analysis skills for IT operations roles.
- Ensure Python 3.6+ is installed.
- Save
test.log
with sample log entries (provided in this repository). - Run the script with optional arguments:
- Filter by log level:
python analyzer.py test.log --level=ERROR
- Filter by timestamp:
python analyzer.py test.log --start="2025-07-14 10:00:00" --end="2025-07-14 10:02:00"
- Filter by message:
python analyzer.py test.log --message="timeout"
- Filter by log level:
- Output includes filtered logs and error count; a
summary.txt
file is generated with the error count.
This project showcases:
- Log parsing and filtering to identify critical issues (e.g., ERROR logs).
- Command-line argument handling for flexible analysis.
- Summarization of operational issues, useful for incident reporting and documentation.
- Skills in Python programming and troubleshooting for IT operations environments.
- Language: Python
- Libraries:
argparse
for command-line arguments,datetime
for timestamp parsing - Functionality:
- Reads log files in format:
YYYY-MM-DD HH:MM:SS - LEVEL - Message
- Filters logs based on optional parameters (start/end time, level, message)
- Outputs filtered logs and counts errors
- Writes error count to
summary.txt
- Reads log files in format:
Running python analyzer.py test.log --level=ERROR
with the provided test.log
:
Filtered logs (2):
2025-07-14 10:00:00 - ERROR - Server timeout occurred
2025-07-14 10:02:00 - ERROR - Database connection failed
Errors found: 2
Generates summary.txt
with content:
Errors: 2
Aligns with IT operations needs for:
- Troubleshooting system issues through log analysis
- Managing and documenting operational incidents
- Supporting tools like Jira/Confluence for knowledge base updates