I have an abc.jar file and it has some Java classes in it. I don't have the source code of it. I want to get logs of the classes/methods that's been hit while debugging.How can I do that?
P.S - I could have used log4j for it but I don't have the source code.
You need to use a profiling tools such as Java's hprof. It is a good introduction to profiling. While not powerful, it is a good start. There are plenty of other useful profiling tools. Just google them.
For hprof, the modes of CPU Usage Sampling Profiles (cpu=samples)
e.g. javac -J-agentlib:hprof=cpu=samples Hello.java
and CPU Usage Times Profile (cpu=times)
e.g. javac -J-agentlib:hprof=cpu=times Hello.java
sound like what you needs. They can tell you what is called and how often. What they won't tell you is the state of variables. This is what debugging is used for given that logging is not an option.
You state in your comment that you know that abc.jar
doesn't use any logging framework.
In that case, it is impossible to get logs from it.
However, what you can do is use a debugger. All IDEs have debuggers. This can help you know the state of the classes being called when you use them.
Let's say if you have abc.jar and it doesn't use any framework for logging, and you don't have any source code as you have mentioned. No, you can't get logs this way.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With