Intercept all XHR Request on a Application server and log them to a log file.
The data in the logfile is an chain of SQL INSERT INTO queries
- Java 8 (JDK)
- Apache Maven
- Web Browser
- Build using Maven
mvn clean install
- Build and run embedded Tomcat (developer)
mvn clean install tomcat7:run
- Deploy as WAR
target/dev-tools##1.0.war
- http://localhost:8080/logging-service
- Mask to create traffic
- LogServlet
- Displays all logfiles under the Apache Tomcats logs directory
- JSF Ajax Interception
- Dummy application in which all XHR requests are intercepted
- Add JS snippets to other applications to log their requests
<script src="/logging-service/resources/js/httpLogger.js"></script> <script src="/logging-service/resources/js/httpLogger-interceptor.js"></script>
CREATE TABLE LOG_REQUESTS (
id int PRIMARY KEY AUTO_INCREMENT,
readyStateDate_1 DATETIME(3),
readyStateDate_2 DATETIME(3),
readyStateDate_3 DATETIME(3),
readyStateDate_4 DATETIME(3),
statusCode INT,
url VARCHAR(255),
browser VARCHAR(255),
requestBody TEXT,
responseHeaders TEXT
);
curl "http://192.168.0.45:8080/logging-service/LogServlet?logFile=MyLogFile2018-06-03.log" > /tmp/dump.sql
mysql -u root -D LOGGING_DATABASE -p < /tmp/dump.sql
SELECT
url,
readyStateDate_1 as start_time,
readyStateDate_2 - readyStateDate_1 as time_till_open_called,
readyStateDate_3 - readyStateDate_2 as time_till_headers_available,
readyStateDate_4 - readyStateDate_3 as time_till_responsetext_loaded,
readyStateDate_4 as end_time,
readyStateDate_4 - readyStateDate_1 as total_time
from
LOG_REQUESTS
ORDER BY
total_time DESC