Here is sample from WebSphere log file-

```none
[1/31/19 13:55:55:567 CET] 0000099c ThreadPoolTas I org.springframework.scheduling.concurrent.ExecutorConfigurationSupport shutdown Shutting down ExecutorService 'sr_taskExecutor'
[1/31/19 13:55:55:568 CET] 0000099c appDispatcher E org.springframework.web.servlet.FrameworkServlet initServletBean Context initialization failed
                                 org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'messageSource' defined in class path resource [context/main/portal-main-context.xml]: Unsatisfied dependency expressed through constructor argument with index 0 of type [no.myapp.portal.core.internal.PortalUserRequestData]: : Cannot find class [no.myapp.api.common.ProxiedClientServiceFactory] for bean with name 'myappapiFactory' defined in ServletContext resource [/WEB-INF/app-context.xml]; nested exception is java.lang.ClassNotFoundException: no.myapp.api.common.ProxiedClientServiceFactory; nested exception is org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [no.myapp.api.common.ProxiedClientServiceFactory] for bean with name 'myappapiFactory' defined in ServletContext resource [/WEB-INF/app-context.xml]; nested exception is java.lang.ClassNotFoundException: no.myapp.api.common.ProxiedClientServiceFactory
Related cause: org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [no.myapp.api.common.ProxiedClientServiceFactory] for bean with name 'myappapiFactory' defined in ServletContext resource [/WEB-INF/app-context.xml]; nested exception is java.lang.ClassNotFoundException: no.myapp.api.common.ProxiedClientServiceFactory
Related cause: org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [no.myapp.api.common.ProxiedClientServiceFactory] for bean with name 'myappapiFactory' defined in ServletContext resource [/WEB-INF/app-context.xml]; nested exception is java.lang.ClassNotFoundException: no.myapp.api.common.ProxiedClientServiceFactory
Related cause: org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [no.myapp.api.common.ProxiedClientServiceFactory] for bean with name 'myappapiFactory' defined in ServletContext resource [/WEB-INF/app-context.xml]; nested exception is java.lang.ClassNotFoundException: no.myapp.api.common.ProxiedClientServiceFactory
Related cause: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource_db811': Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: Context: Cell-01, name: ds_appng_811: First component in name ds_appng_811 not found. [Root exception is org.omg.CosNaming.NamingContextPackage.NotFound: IDL:omg.org/CosNaming/NamingContext/NotFound:1.0]
    at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:752)
    at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:193)
    at com.ibm.ws.runtime.component.CompositionUnitMgrImpl$CUInitializer.run(CompositionUnitMgrImpl.java:985)
    at com.ibm.wsspi.runtime.component.WsComponentImpl$_AsynchInitializer.run(WsComponentImpl.java:524)
    at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1892)
Caused by: org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [no.myapp.api.common.ProxiedClientServiceFactory] for bean with name 'myappapiFactory' defined in ServletContext resource [/WEB-INF/app-context.xml]; nested exception is java.lang.ClassNotFoundException: no.myapp.api.common.ProxiedClientServiceFactory
    at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1281)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType(AbstractAutowireCapableBeanFactory.java:575)
    at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:745)
    ... 47 more
Caused by: java.lang.ClassNotFoundException: no.myapp.api.common.ProxiedClientServiceFactory
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at com.ibm.ws.bootstrap.ExtClassLoader.findClass(ExtClassLoader.java:243)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    ********Skip Trace************
[1/31/19 13:55:57:004 CET] 00000001 WSChannelFram A   CHFW0019I: The Transport Channel Service has started chain HttpQueueInboundDefaultSecure.
[1/31/19 13:55:57:006 CET] 00000001 TCPChannel    I   TCPC0001I: TCP Channel TCP_3 is listening on host *  (IPv6) port 9048.
[1/31/19 13:55:57:008 CET] 00000001 WSChannelFram A   CHFW0019I: The Transport Channel Service has started chain WCInboundAdminSecure.
[1/31/19 13:55:57:010 CET] 00000001 WSChannelFram A   CHFW0019I: The Transport Channel Service has started chain WCInboundDefaultSecure.
[1/31/19 13:55:57:011 CET] 00000001 WSChannelFram A   CHFW0019I: The Transport Channel Service has started chain SOAPAcceptorChain1.
[1/31/19 13:55:57:012 CET] 00000001 WSChannelFram A   CHFW0019I: The Transport Channel Service has started chain SOAPAcceptorChain2.
[1/31/19 13:55:57:012 CET] 00000001 WSChannelFram A   CHFW0019I: The Transport Channel Service has started chain SOAPAcceptorChain3.
[1/31/19 13:55:57:013 CET] 00000001 WSChannelFram A   CHFW0019I: The Transport Channel Service has started chain SOAPAcceptorChain4.
[1/31/19 13:55:57:014 CET] 00000001 WSChannelFram A   CHFW0019I: The Transport Channel Service has started chain SOAPAcceptorChain5.
[1/31/19 13:55:57:014 CET] 00000001 WSChannelFram A   CHFW0019I: The Transport Channel Service has started chain SOAPAcceptorChain6.

```

Here I want to fetch TimeStamp of the `org.omg.CosNaming.NamingContextPackage.NotFound` occurrence which is few lines above (`1/31/19 13:55:55:568 CET`).

So far below code is working if target string occurs in single line-

```
code="org.omg.CosNaming.NamingContextPackage.NotFound"
with open('Server01/SystemOut.log',"r") as data:
    for i in data:
       if code in i.strip():
          val =  i[i.find("[")+1:i.find("]")].strip()
          print i ##Result stack but single line
          print val  ##Result only timestamp

```

**Expected Result:**
list of time stamps against specific exception string

```
org.omg.CosNaming.NamingContextPackage.NotFound - ['1/31/19 13:55:55:568 CET']

```