Trace issue: Need help badly... I am dying here

Hello,

I need help. Can anyone recommend me anything which can provide me with the ability to trace a java application.

By the trace, what I really mean to say is some sort of a log that shows which object sends message to another object and which object instantiates another object.

I will be really gratefull and thank you very much in advance

regards

Tauseef

[407 byte] By [taisrar] at [2007-9-26 3:36:13]
# 1
I wouldn't have any idea... but if I want to track my own Java program.. I simply add Strings in the program... Sander
SanderSander at 2007-6-29 12:07:26 > top of Java-index,Archived Forums,Java Programming...
# 2
If you have time, you can look at 'aspectJ'.This is a tool for Aspect Oriented Programming. You can "easily" instrument your code to have lot af trace... http://www.aspectj.orgI have made some presentation slides about...Floweb
floweb at 2007-6-29 12:07:26 > top of Java-index,Archived Forums,Java Programming...
# 3

I guess you basically need a LogManager class

which writes the msgs in a log file

but you have to call its methods in your other objects for whatever msg you intend to write into a log file

something like

import java.io.*;

public class MyLogManager {

FileOutputStream fout;

public MyLogManager() throws Exception{

FileWriter fout = new FileWriter("mylogfile");

}

public void log( String message) {

StringBuffer theBuf = new StringBuffer();

try {

// may put time here

theBuf.append(' ');

theBuf.append(':');

theBuf.append(message);

writeMsg(theBuf.toString());

} //end try

catch (Exception ex) {

ex.printStackTrace();

}

}

private void writeMsg(String str) throws Exception{

fout.write(str.getBytes());

}

}

Please modify this code to your requirements

insoft at 2007-6-29 12:07:27 > top of Java-index,Archived Forums,Java Programming...
# 4
Use the Java tool 'hprof' to trace method calls and object instantiation. Take a look @ http://java.sun.com/products/jdk/1.2/docs/guide/jvmpi/jvmpi.html for usage instructions.
treydrake at 2007-6-29 12:07:27 > top of Java-index,Archived Forums,Java Programming...