import java.util.regex.*; server = "brutus.apache.org"; user = "mrdon"; prompt = ":~$"; localRssPath = ""; remoteRssPath = "http://myserver.com/feeds/"; remoteLogPath = "/usr/local/tomcat/tomcat-confluence/logs/catalina.out"; conn.connect(server, user); conn.setTimeout(20000); conn.waitFor(prompt); conn.sendLine("tail -n 5000 "+remoteLogPath); entries = new ArrayList(); entry = ""; id = conn.waitForMux(new String[]{"ERROR", prompt}); while (id == 0) { id = conn.waitForMux(new String[]{"\r\n", prompt}); if (id == 0) { line = conn.lastLine(); if (line.contains("WARN") || line.contains("DEBUG") || line.contains("INFO")) { if (entry != null) { entries.add(entry); entry = null; } continue; } if (line.contains("ERROR")) { entry = line; } else if (entry != null) { entry += "\n"+line; } } } Collections.reverse(entries); out = new FileWriter(localRssPath+server+".xml"); rss = new PrintWriter(out); rss.println(""); rss.println(""); rss.println(""); rss.println(""+server+" log errors"); rss.println(""+remoteRssPath+server+".xml"); rss.println(""+server+" Tomcat Log errors"); for (x=0; x", ">"); entry = entry.replaceAll("\n", "
"); firstLine = entry; if (entry.contains("
")) { firstLine = entry.substring(0, entry.indexOf("
")); } rss.println(""); rss.println(""+firstLine+""); rss.println(""+remoteRssPath+x+".txt"); rss.println(""); rss.println(""); } rss.println("
"); rss.println("
"); rss.close(); conn.disconnect();