繁体   English   中英

从 Java 中的日志文件中提取时间戳和异常

[英]Extracting timestamp and and exception from a log file in Java

我需要在日志文件中提取时间戳和异常,然后需要将时间戳与异常分开

> > 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

在上面的日志文件中,我需要提取它们发生的异常和时间戳。然后我需要单独存储它们,以便我可以将我的时间戳与另一个日志文件中的另一个时间戳进行比较

output 应该如下所示

> 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

您还应该发布您 r 在代码中所做的事情,以便任何人都可以了解一个异常可能有多种原因。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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