我们希望监控Tomcat catalina.log。 但每个错误消息都有多行。 我们来自Monitoring-Tool(HPOM)的Logfileadapter仅适用于单行消息。 有人有解决方案吗?
示例:
15.07.2015 15:09:59 com.sun.xml.ws.transport.http.servlet.WSServletContextListener contextDestroyed
INFO: WSSERVLET13: JAX-WS context listener destroyed
from here ---->
15.07.2015 15:10:01 org.apache.catalina.connector.MapperListener destroy
WARNUNG: Error unregistering MBeanServerDelegate
java.lang.NullPointerException
at org.apache.catalina.connector.MapperListener.destroy(MapperListener.java:162)
at org.apache.catalina.connector.Connector.stop(Connector.java:1180)
at org.apache.catalina.core.StandardService.stop(StandardService.java:593)
at org.apache.catalina.core.StandardServer.stop(StandardServer.java:744)
at org.apache.catalina.startup.Catalina.stop(Catalina.java:616)
at org.apache.catalina.startup.Catalina$CatalinaShutdownHook.run(Catalina.java:659)**
to here ----->
15.07.2015 15:10:01 org.apache.coyote.http11.Http11Protocol destroy
INFO: Stopping Coyote HTTP/1.1 on http-8080
15.07.2015 15:10:01 org.apache.catalina.connector.Connector stop
SCHWERWIEGEND: Coyote connector has not been started
答案 0 :(得分:0)
我已按如下方式解决了这个问题:
sed -n '/15.07.2015 15:10:01 org.apache.catalina.connector.MapperListener destroy/,/^[0-9][0-9].[0-9][0-9].[0-9][0-9][0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9]/p' catalina.log|head -n -1
但是这里使用了SED。所以它在Windows中不起作用。