我是Stackoverflow的新手。如果我没有做好彻底搜索的功课,请原谅我。我在解析tomcat localhost日志和catalina.out文件中的文本时遇到问题。我们都知道,我们在这两个文件中都会收到严重警报。我想要一个脚本或免费软件,它将帮助我单独解析严重警报并发送到我的电子邮件。
例如:
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。
真的吗?
bash脚本有什么问题:
grep ^SEVERE catalina.out | mail foo@bar.com
快照要求?试试这个:
grep ^SEVERE catalina.out > tmpFile
diff tmpFile snapshot | mail foo@bar.com
mv tmpFile snapshot