Monday, 15 April 2013

logging - Is there a java library which can be used to generate replay logs such that , application can replay the actual bug from the log file -



logging - Is there a java library which can be used to generate replay logs such that , application can replay the actual bug from the log file -

consider scenario java application error occurs , can see exception stack trace. now, if can re-create issue somehow , turn replay logs on, utilize replay log file inject same state due exception happened . want know if there existing java library can used such thing. or have design application such can cater such requirements ?

for illustration consider next class , output. after parsing output , using reflection can replay div 0 scenario.

so know if there existing java library provides such functionality ?

public class myclass { /** * @param args */ public static void main(string[] args) { myclass myclass = new myclass(); //scenario 1 int div1 = myclass.div(1,2); int div2 = myclass.div(1,0); } public int div(int firstarg,int secondarg){ log(firstarg + "," + secondarg); homecoming firstarg / secondarg; } private void log(string args){ stringbuffer sb = new stringbuffer(); sb.append("\nclass " + getclass().getname()); sb.append(" method " + getmethodname(1)); sb.append(" args " + args); system.out.println("log # " + sb.tostring()); } // picked http://stackoverflow.com/questions/442747/getting-the-name-of-the-current-executing-method public static string getmethodname(final int depth) { final stacktraceelement[] ste = thread.currentthread().getstacktrace(); homecoming ste[ste.length - 1 - depth].getmethodname(); //thank tom tresansky } }

**

log # class myclass method div args 1,2 exception in thread "main" log # class myclass method div args 1,0 java.lang.arithmeticexception: / 0 @ myclass.div(myclass.java:19) @ myclass.main(myclass.java:12)

**

cchronon solution. chronon, have purchase licence,.or can utilize chronon plugin intellij thought ultimate free.

http://blog.jetbrains.com/idea/2014/03/try-chronon-debugger-with-intellij-idea-13-1-eap/?_ga=1.102962688.1259655133.1391072454 solution you!

java logging

No comments:

Post a Comment