Spring-boot(Java) web service that can retrieve logs from "\var\log" directory in reverse chronological order with the following parameters:
- "filename" - the file name [required]
- "searchword" - the word to filter for in every line [optional]
- "limit" - the maximum number of lines to return, default is 100. Set as 0 if all content is intended.[optional]
- Warning: service might return 500 if all content is requested for a large file.
- Spring boot frame work with Maven. You can follow the official website to install spring boot link
In the source directory, run
./mvnw packageto build the service./mvnw testto run unit-tests./mvnw spring-boot:runto start the service, service will be started on localhost:8080.
Some example commands are show below:
curl -sS 'http://localhost:8080/getlog?filename=install.log'
curl -sS 'http://localhost:8080/getlog?filename=install.log&searchword=install'
curl -sS 'http://localhost:8080/getlog?limit=5&filename=install.log&searchword=install'
curl -sS 'http://localhost:8080/getlog?limit=0&filename=install.log&searchword=install'