I had posed a similar topic some time back but I want some additional information from the input file.
The log file is as shown...
I want the Perl script to return everything from the file called "App.log" shown above, that matches the line containing "ID_UNHANDL ED", i.e. the line ...
which is the last line of that exception. It shouldn't include the next "[ERROR]" line.
I could come up with the following code but it returned only the lines containing the strings mentioned.
The log file is as shown...
Code:
[ERROR] [06 Apr 2009 09:45:56] [Trace] [WebContainer : 48] - App Number: 0 [ERROR] [06 Apr 2009 09:45:56] [Trace] [WebContainer : 48] - Response for AE Completion No such RID Found [ERROR] [06 Apr 2009 09:46:02] [Trace] [WebContainer : 20] - infrastructure:ID_UNHANDLED: An un-handled server exception occurred. Please contact your administrator. at sun.reflect.GeneratedMethodAccessor186.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java(Compiled Code)) at java.lang.reflect.Method.invoke(Method.java(Compiled Code)) at com.ibm.rmi.util.ProxyUtil$2.run(ProxyUtil.java(Compiled Code)) at java.security.AccessController.doPrivileged1(Native Method) at java.security.AccessController.doPrivileged(AccessController.java(Compiled Code)) at com.ibm.rmi.util.ProxyUtil.invokeWithPrivilege(ProxyUtil.java(Compiled Code)) at com.ibm.CORBA.iiop.ClientDelegate.invoke(ClientDelegate.java(Compiled Code)) at $Proxy90.invoke(Unknown Source) nested exception is: infrastructure:RUN_ID_RUNTIME: A runtime exception occurred: javax.transaction.RollbackException. at sun.reflect.GeneratedMethodAccessor186.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java(Compiled Code)) at java.lang.reflect.Method.invoke(Method.java(Compiled Code)) at com.ibm.rmi.util.ProxyUtil$2.run(ProxyUtil.java(Compiled Code)) at java.security.AccessController.doPrivileged1(Native Method) at java.security.AccessController.doPrivileged(AccessController.java(Compiled Code)) at com.ibm.rmi.util.ProxyUtil.invokeWithPrivilege(ProxyUtil.java(Compiled Code)) at com.ibm.CORBA.iiop.ClientDelegate.invoke(ClientDelegate.java(Compiled Code)) at $Proxy90.invoke(Unknown Source) [ERROR] [06 Apr 2009 09:46:02] [Trace] [WebContainer : 49] - infrastructure:ID_UNHANDLED: An un-handled server exception occurred. Please contact your administrator. at sun.reflect.GeneratedMethodAccessor186.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java(Compiled Code)) at java.lang.reflect.Method.invoke(Method.java(Compiled Code)) at com.ibm.rmi.util.ProxyUtil$2.run(ProxyUtil.java(Compiled Code)) at java.security.AccessController.doPrivileged1(Native Method)
Code:
"[ERROR] [06 Apr 2009 09:46:02] [Trace] [WebContainer : 20] - infrastructure:ID_UNHANDLED: An un-handled server exception occurred. Please contact your administrator." upto the next occurence of the string "[ERROR]" i.e. it should include the following ... [ERROR] [06 Apr 2009 09:46:02] [Trace] [WebContainer : 20] - infrastructure:ID_UNHANDLED: An un-handled server exception occurred. Please contact your administrator. .... ... ... nested exception is: infrastructure:RUN_ID_RUNTIME: A runtime exception occurred: ... ... ... at $Proxy90.invoke(Unknown Source)
I could come up with the following code but it returned only the lines containing the strings mentioned.
Code:
while ($line = <LOGFILE>) { # chomp $line; if ($line =~ /^\[ERROR\](.*?)infrastructure:ID_UNHANDLED:.*$/) { push @message, $line; $match = 1; next; } if ($match && ($line =~ /^nested exception is:/)) { $line = <LOGFILE>; push @message, $line; $match = 0; next; } }
Comment