0

With a standard webapp running in Tomcat with the Spring Framwork and Log4J logging to catalina.out I need to have a better access to logs than manual SSH and tail -f catina.out

I already know of some solution like logstash, ... but they require to send the log to a centralized server. I went through a lot of answers of various websites but none satisfies my needs. I just want to have access to the logs in a web browser on the same web server.

Is there any simple and straightforward way to do that ?

Update

I want to to that because I cannot always SSH and tail -f the logs because of the firewall IP security. I need to be able to see these logs from anywhere as long as I have an internet access to such a secure live web console.

singe3
  • 2,065
  • 4
  • 30
  • 48
  • You could setup Apache to serve the folder where your tomcat logs are – francesco foresti Jun 04 '15 at 10:24
  • @francescoforesti my browser is on my computer (Chrome or whatever) and the web server is on a distant host (in AWS cloud). – singe3 Jun 04 '15 at 10:25
  • yep, I knew I misunderstood.. see the edit – francesco foresti Jun 04 '15 at 10:26
  • @francescoforesti I don't want to serve a file. It would be too long to refresh. I need a live webpage viewer that appends new lines when they appear in the file. I'm surprised this is not a default feature of Log4j, such a basic feature. – singe3 Jun 04 '15 at 10:27
  • understood.. maybe [this ServerFault question](http://serverfault.com/questions/9691/viewing-logs-on-a-remote-linux-server), or [this tomcat-related question](http://stackoverflow.com/questions/2881854/i-need-to-read-a-remote-file-with-logs-from-a-tomcat) can help – francesco foresti Jun 04 '15 at 10:30
  • @francescoforesti Already saw these subjects but thanks anyway. They are not web viewers. I'm looking for a live console in a web gui. – singe3 Jun 04 '15 at 10:33
  • if you elaborate what makes **live console in web gui** better than **tail -f**, you may get more specific answers. – elsadek Jun 04 '15 at 10:57
  • @elsadek SSH requires me to be on a specific IP due to firewall security. I need to have a secured web GUI to access the logs from anywhere. – singe3 Jun 04 '15 at 11:04
  • Have you tried Logstash+ElasticSearch+Kibana? Kibana is a web GUI to view logs collected by Logstash and indexed by ElasticSearch (all 3 tools have to be installed directly on the web server box) – xav Jun 04 '15 at 20:45
  • @xav it is way ahead of what I need. I'm just looking for a live web console. I dont need all these tools just to do that, don't you think ? – singe3 Jun 04 '15 at 21:12
  • @singe31 Well, it depends on your needs (I, too, prefer lightweight and straight-forward tools in this case). If you only need to see raw text, then have you thought about writing a few lines of PHP that will read the end of your log file? – xav Jun 04 '15 at 21:34
  • @xav I wanted it to be integrated in the existing app (Java with Spring framework) and be accessible with some url like domain/logs for example – singe3 Jun 08 '15 at 08:16
  • Is remote logging, for example to a logstash/ElasticSearch instance, an option? If so, then look here: http://stackoverflow.com/questions/25429377/how-can-i-integrate-tomcat6s-catalina-out-file-with-logstash-elasticsearch – mp911de Jun 08 '15 at 17:15
  • @mp911de No I'm afraid it's not an option. – singe3 Jun 09 '15 at 09:47

1 Answers1

0

Give logsniffer a try. It's a simple standalone Java web application which can run on the same host. log4j log format is supported out of the box, just type in the conversion pattern and the logs will be parsed properly. You can tail, search and monitor the logs in real-time. Last but not least, logsniffer is open source.

Disclaimer: This is my own project.

Michael Blank
  • 344
  • 1
  • 2