简体   繁体   中英

Extracting timestamp and and exception from a log file in Java

I need to extract timestamps and exceptions in a log file and after need to separate timestamps from exception

> > 2022.01.07 13:28:49 > [CDEThreadPool-thread-10] - Exception caught in doInBackground runnable, ThreadId = 56, Exception = ServiceCommunicationException: javax.ejb.EJBException: java.nio.channels.ClosedChannelException
common.service.ServiceCommunicationException: javax.ejb.EJBException: java.nio.channels.ClosedChannelException
    at .ejb.AbstractRequestDecorationProxy.invoke(AbstractRequestDecorationProxy.java:116)
    at .accesslog.provider.service.remote.LogServiceEjbClient.create(LogServiceEjbClient.java:65)
    at .provider.client.frame.facade.impl.AccessLogFacadeImpl.create(AccessLogFacadeImpl.java:97)
    at accesslog.provider.AccessLogAsyncPersister.doInBackground(AccessLogAsyncPersister.java:24)
    at .accesslog.provider.AccessLogAsyncPersister.doInBackground(AccessLogAsyncPersister.java:10)
    at .framework.ExtendedNonSOCBoundSwingWorker$2.run(ExtendedNonSOCBoundSwingWorker.java:276)
     


Caused by: javax.ejb.EJBException: java.nio.channels.ClosedChannelException
    at org.jboss.ejb.protocol.remote.EJBClientChannel$MethodInvocation.handleClosed(EJBClientChannel.java:1286)
    at org.jboss.remoting3.util.InvocationTracker.connectionClosed(InvocationTracker.java:222)
    at org.jboss.remoting3.util.InvocationTracker.lambda$new$0(InvocationTracker.java:70)
    at org.jboss.remoting3.spi.SpiUtils.safeHandleClose(SpiUtils.java:50)
    at org.jboss.ejb.protocol.remote.EJBClientChannel$MethodInvocation.handleClosed(EJBClientChannel.java:1286)
    at org.jboss.remoting3.util.InvocationTracker.connectionClosed(InvocationTracker.java:222)
    at org.jboss.remoting3.util.InvocationTracker.lambda$new$0(InvocationTracker.java:70)
    at org.jboss.remoting3.spi.SpiUtils.safeHandleClose(SpiUtils.java:50)
    at org.jboss.remoting3.spi.AbstractHandleableCloseable$CloseHandlerTask.run(AbstractHandleableCloseable.java:520)
    at org.jboss.remoting3.spi.AbstractHandleableCloseable.runCloseTask(AbstractHandleableCloseable.java:425)
    at org.jboss.remoting3.spi.AbstractHandleableCloseable.closeComplete(AbstractHandleableCloseable.java:286)
    at org.jboss.remoting3.remote.RemoteConnectionChannel.closeAction(RemoteConnectionChannel.java:510)
    at org.jboss.remoting3.spi.AbstractHandleableCloseable.closeAsync(AbstractHandleableCloseable.java:368)
    at org.jboss.remoting3.remote.RemoteConnectionHandler.closeAllChannels(RemoteConnectionHandler.java:623)
    at org.jboss.remoting3.remote.RemoteConnectionHandler.sendCloseRequest(RemoteConnectionHandler.java:245)
    at org.jboss.remoting3.remote.RemoteConnectionHandler.closeAction(RemoteConnectionHandler.java:598)
    at org.jboss.remoting3.spi.AbstractHandleableCloseable.closeAsync(AbstractHandleableCloseable.java:368)
    at org.jboss.remoting3.ConnectionImpl.closeAction(ConnectionImpl.java:78)
    at org.jboss.remoting3.spi.AbstractHandleableCloseable.close(AbstractHandleableCloseable.java:150)
    at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758)
    at java.awt.EventQueue.access$500(EventQueue.java:97)
    at java.awt.EventQueue$3.run(EventQueue.java:709)
    at java.awt.EventQueue$3.run(EventQueue.java:703)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:728)
    at client.framework.core.internal.TrackingEventQueue.dispatchEvent(TrackingEventQueue.java:169)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:205)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
Caused by: java.nio.channels.ClosedChannelException: null
    ... 38 common frames omitted
> 2022.01.07 13:36:01 > [CDEThreadPool-thread-10] - javax.ejb.EJBException: java.nio.channels.ClosedChannelException
    at framework.CDEThreadPool$WrappedRunnable.run(CDEThreadPool.java:143)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)
Caused by: javax.ejb.EJBException: java.nio.channels.ClosedChannelException
    at org.jboss.ejb.protocol.remote.EJBClientChannel$MethodInvocation.handleClosed(EJBClientChannel.java:1286)
    at org.jboss.remoting3.util.InvocationTracker.connectionClosed(InvocationTracker.java:222)
    at org.jboss.remoting3.util.InvocationTracker.lambda$new$0(InvocationTracker.java:70)
    at org.jboss.remoting3.spi.SpiUtils.safeHandleClose(SpiUtils.java:50)
    at org.jboss.remoting3.spi.AbstractHandleableCloseable$CloseHandlerTask.run(AbstractHandleableCloseable.java:520)
    at org.jboss.remoting3.spi.AbstractHandleableCloseable.runCloseTask(AbstractHandleableCloseable.java:425)
    at org.jboss.remoting3.spi.AbstractHandleableCloseable.closeComplete(AbstractHandleableCloseable.java:286)
    at org.jboss.remoting3.remote.RemoteConnectionChannel.closeAction(RemoteConnectionChannel.java:510)
    at org.jboss.remoting3.spi.AbstractHandleableCloseable.closeAsync(AbstractHandleableCloseable.java:368)
    at org.jboss.remoting3.remote.RemoteConnectionHandler.closeAllChannels(RemoteConnectionHandler.java:623)
    at org.jboss.remoting3.remote.RemoteConnectionHandler.sendCloseRequest(RemoteConnectionHandler.java:245)
    at org.jboss.remoting3.remote.RemoteConnectionHandler.closeAction(RemoteConnectionHandler.java:598)
    at org.jboss.remoting3.spi.AbstractHandleableCloseable.closeAsync(AbstractHandleableCloseable.java:36
    at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758)
    at java.awt.EventQueue.access$500(EventQueue.java:97)
    at java.awt.EventQueue$3.run(EventQueue.java:709)
    at java.awt.EventQueue$3.run(EventQueue.java:703)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:728)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:205)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
Caused by: java.nio.channels.ClosedChannelException: null
    ... 38 common frames omitted
> 2022.01.07 13:36:01 > [CDEThreadPool-thread-7] - javax.ejb.EJBException: java.nio.channels.ClosedChannelException
client.framework.ExtendedNonSOCBoundSwingWorker$2.run(ExtendedNonSOCBoundSwingWorker.java:276)
    at client.framework.CDEThreadPool$WrappedRunnable.run(CDEThreadPool.java:143)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)
Caused by: javax.ejb.EJBException: java.nio.channels.ClosedChannelException
    at client.framework.core.internal.TrackingEventQueue.dispatchEvent(TrackingEventQueue.java:169)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:205)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
Caused by: java.nio.channels.ClosedChannelException: null
    ... 38 common frames omitted

In the above log file I need to extract exceptions and timestamps they occurred.Then I need to store them separately so I can compare my timestamp with another timestamp from another log file

The output should be like below

> 2022.01.07 13:28:49  Exception caught in doInBackground runnable, ThreadId = 56, Exception = ServiceCommunicationException: javax.ejb.EJBException: java.nio.channels.ClosedChannelException


2022.01.07 13:36:01  javax.ejb.EJBException: java.nio.channels.ClosedChannelException

2022.01.07 13:36:01 javax.ejb.EJBException: java.nio.channels.ClosedChannelException

U should also post, what u r doing in the code so that any one can get the idea there may be multiple reasons for one exception.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM