package example.catalina;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.logging.Level;
import java.util.logging.Logger;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import example.catalina.config.ConfigException;
import example.catalina.config.LogFileFinder;

public class LogServlet extends HttpServlet {
    private static final Logger LOGGER = Logger.getLogger(LogServlet.class.getName());

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        try {
            LogFileFinder logFinder = new LogFileFinder(Runtime.getRuntime());
            String logFile = logFinder.getLogs().get(0);

            LOGGER.info("Reading logfile " + logFile);
            InputStream is = new FileInputStream(logFile);
            int avail = is.available();

            is.skip(avail - 80 * 80);

            byte[] data = new byte[is.available()];
            is.read(data);
            resp.getOutputStream().write(data);

        } catch (ConfigException e) {
            LOGGER.log(Level.WARNING, "An error occurred.", e);
        }

    }
}

@@ -100,32 +100,55 @@
 io.InputStream;%0A
+import java.util.List;%0A
 import java.util
@@ -659,16 +659,20 @@
 uest req
+uest
 , HttpSe
@@ -689,16 +689,20 @@
 nse resp
+onse
 ) throws
@@ -748,16 +748,17 @@
   try %7B%0A
+%0A
         
@@ -828,16 +828,17 @@
 ime());%0A
+%0A
         
@@ -845,22 +845,25 @@
     
+List%3C
 String
+%3E
  log
-File
+s
  = l
@@ -880,16 +880,270 @@
 etLogs()
+;%0A            if (logs.size() == 0) %7B%0A                response.setStatus(503);%0A                response.getOutputStream().write((new String(%22No tomcat process found.%22)).getBytes());%0A                return;%0A            %7D%0A            String firstLog = logs
 .get(0);
@@ -1189,23 +1189,24 @@
 ile %22 + 
-logFile
+firstLog
 );%0A     
@@ -1253,15 +1253,16 @@
 eam(
-logFile
+firstLog
 );%0A 
@@ -1435,16 +1435,20 @@
     resp
+onse
 .getOutp

Handle missing tomcat process.