Reputation: 55
I want to get the log file form tomcat .How to retrieve and get it downloaded from tomcat using java. I am using Java6 and Tomcat7
Upvotes: 2
Views: 2229
Reputation: 4951
If security is not an issue, you can add tomcat log dir to tomcat web dir and enable file listing. and tomcat will play as an http server and log files are static files. you can list and download the log files.
Back to your original requirements, you want to download tomcat log files ( very likely via http) using java as client.
1) So first there should be a http server. you can use python. go into tomcat log dir and run nohup python -m SimpleHTTPServer 8000 > /dev/null &
it will start a http server on current dir using port 8000
2) using your browser to open HOST_IP:8000 and check if the http server works. it should list all log files in the dir.
3) write your java code to connect to the http server and download the file. apache http client should do this job.
Upvotes: 0
Reputation: 399
You can retrieve log file using System.getProperty("catalina.base") + "/logs".
Upvotes: 2