是否有任何脚本或其他方法来解析tomcat日志?

时间:2012-07-11 06:39:28

标签: python ruby tomcat6 logparser catalina.out

我是Stackoverflow的新手。如果我没有完成我的搜索作业,那么请原谅我。我在解析tomcat localhost log和catalina.out文件中的文本时遇到问题。我们都知道,我们会在这些文件中收到严重警报。我想要一个脚本或免费软件,它可以帮助我单独解析SEVERE警报并发送到我的电子邮件。

例如:

SEVERE: Error listenerStart
6 Jul, 2012 2:04:40 PM org.apache.catalina.core.StandardContext start
SEVERE: Context [**********] startup failed due to previous errors
6 Jul, 2012 2:04:40 PM org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc

SEVERE: The web application [**************] registered the JDBC driver [com.mysql.jdbc.Driver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
6 Jul, 2012 2:04:40 PM org.apache.catalina.startup.HostConfig deployWAR

INFO: Deploying web application archive server.war
6 Jul, 2012 2:04:40 PM org.apache.catalina.loader.WebappClassLoader validateJarFile

脚本必须从“SEVERE:....”解析到文本,直到下一个“SEVERE:....”或文件的结尾。该脚本可以是shell,python或ruby。

1 个答案:

答案 0 :(得分:4)

真的?

bash脚本有什么问题:

grep ^SEVERE catalina.out | mail foo@bar.com

快照要求?试试这个:

grep ^SEVERE catalina.out > tmpFile
diff tmpFile snapshot | mail foo@bar.com
mv tmpFile snapshot