How to get logs from a .jar file?

I have an abc.jar file and it has some Java classes in it. I have no source code. I want to get the logs of classes / methods that were deleted during debugging. How can i do this?

PS - I could use log4j for it, but I have no source code.

+5
source share
3 answers

In your comment, you indicate that you know that abc.jar does not use the logging framework.

In this case, it is not possible to get logs from it.

However, what you can do is use a debugger. All IDEs have debuggers. This can help you find out the state of classes called when they are used.

+2
source

Say if you have abc.jar and it does not use any frameworks for logging, and you do not have the source code, as you already mentioned. No, you cannot get the logs this way.

+2
source

You need to use profiling tools like Java hprof . This is a good introduction to profiling. Although not very effective, this is a good start. There are many other useful tools for profiling. Just go to Google.

For hprof processor usage sampling profile modes (cpu = samples)

 eg javac -J-agentlib:hprof=cpu=samples Hello.java 

and CPU usage time (cpu = times)

 eg javac -J-agentlib:hprof=cpu=times Hello.java 

sounds the way you need it. They can tell you what is called and how often. What they will not tell you is the state of the variables. This is what is used for debugging, since registration is not an option.

+2
source

All Articles