A Java command-line application that analyzes mixed log files, classifies log entries (APM logs, Request logs, and Application logs), and outputs structured JSON summaries. The project is built using the Chain of Responsibility design pattern for scalable and modular log processing.
📄 Answers to Part 1 and the class diagram are available in:
202 answers individual project.pdf
mvn clean package
mv target/logfileanalyzer-1.0-SNAPSHOT-jar-with-dependencies.jar log-analyzer.jarjava -jar log-analyzer.jar --file sample_input_logs-1.TXTThe output files will be created inside the
src/output/directory.
mvn clean testAfter execution, the following JSON files are generated:
apm.json– Aggregates for metrics like CPU, memory, disk, etc.application.json– Counts of log levels (e.g., ERROR, INFO, DEBUG)request.json– API response time stats and status code summaries
The application uses the Chain of Responsibility pattern. Each handler (APMLogHandler, ApplicationLogHandler, RequestLogHandler, NullLogHandler) checks if it can process a log line and, if not, passes it to the next handler.
Each handler uses a corresponding aggregator:
APMLogAggregatorApplicationLogAggregatorRequestLogAggregator
These aggregators implement a shared interface: LogAggregator.
timestamp=2024-04-12T22:00:00Z metric=cpu_usage_percent value=72
timestamp=2024-04-12T22:00:01Z level=INFO message="Starting application"
timestamp=2024-04-12T22:00:02Z request_method=POST request_url="/api/update" response_status=200 response_time_ms=120
Jahnavi Kedia
CMPE 202 – Individual Project
San Jose State University