There is a project, that I am working on. I am new to that project. Problem is when I click on submit button on certain JSP page, it prints something on console. What ever printed is definitely inside System.out.println(). But I am unable to track that SOP. I also searched that piece of value through search tool in eclipse. But I couldn't find it. Is there any way to do that in debug mode, means can I add breakpoint to my whole project. Guide me. I am stuck.
Logging is a better way to track SOP kind of things. Use the Log class to log info about the the app, it's got Debug, Verbose, Info, Warning and other stuff
Related
I need to count the number of times a given line of code is hit during execution. I want to use it via debugging tool on my IDE and not a code or performance tool solution.
I am already using YourKit to profile the project, and do not want number of line calls via this tool.
I also do not want to count hits using code (with System.out.print and a variable) because I will be checking the procedure at different branches.
I already checked IntelliJ IDEA help.
Also checked both this posts:
Debugging and counting breakpoint hits
Counting breakpoint hits
But none of them replies to what I am looking for.
I am currently using IntelliJ's breakpoint options: Log to console .
The way I am using the breakpoint option in IntelliJ I get a log message every time the breakpoint is hit, and then I have to count the number of messages.
I would like to get an actual number of hits so I do not have to count messages.
If anyone knows a simple direct solution to achieving this via IntelliJ I really appreciate. Thanks in advance.
The Overhead tab in the Debugger view has a "Hits" column. You don't even have to have Suspend or Log to Console being enabled for the breakpoint to be counted. See the help page Monitor debugger overhead.
Scroll to the end, and watch the line number
The approach of DaSqy Stc is good, but it doesn't work when there are other log messages are printed or if you want to track multiple breakpoints individually.
Solution is to keep the option "log to console" on and click inside the console, press [Ctrl]+[F] and search after "Breakpoint reached at RemoveFromList.remove(RemoveFromList.java:38)" and it says 1/6. The right number is the one you want.
I'm writing a program in Java using JOptimizer for linear programming. Is there a way to cancel all those DEBUG prints of the library to the console?
I troubled with the same problem.
Joptimizer uses log4j to print logs, so put the log4j.properties file in your directory.
If you write "log4j.rootLogger=OFF" in it, all debug logs go away.
And if you use sbt, you should put it in src/main/resources/. It works fine.
I don't know about other cases , but it will work if you put it in an appropriate place.
I have had a problem with a custom component I am writing. The issue seems to be a resource not loading properly (not sure why) at design-time.
To track it down I'd like to put in some debug-code that will execute at design-time, and give output in form of some messages.
Is there a log or something similar that can be written to at design-time?
Thanks
There's a really nice trick you can use to add debug statements in IntelliJ without actually changing the code. The answer is to use non-suspending breakpoints.
Add a breakpoint at the necessary point in the code, then right click on it. De-select "Suspend", and then put whatever you want in the "Log evaluated expression" - this will give you access to the fields of the instance.
Run your app in debug mode, and you'll get debugging info in the console without having to manually examine everything.
Hi i'm new to java and when I press the debug button it is not going into debug mode.
After clicking on the drop down arrow next to the icon it says 1 new configuration and when that launches it just says in the console 'OK'. If I go on debug as it just says none applicable.
If I go on debug configurations I don't really understand what I'm supposed to go on to get it into debug mode as i guess it is something to do with the configuration?
If it helps I'm trying to write code for a project, not android or anything like that. Hope this is enough information, thanks.
Did you remember to add a breakpoint somewhere? If not, add a breakpoint! You can do that by double clicking one of the line numbers in your source code.
You may also want to check the toolbar to see if you accidentally checked the "skip all breakpoints" option.
I am working on a java ee web application in NetBeans. I am trying to debug the behavior of the application but the behavior I'm seeing is confusing.
I am running the application through NetBeans in Tomcat. Within NetBeans, I select "Debug" from the root of the Project Tree and I can send one request to the application I've written. Breakpoints are hit and I get unique results from the application.
However, every subsequent time I try to send a request to my application, I get the exact same incorrect result (even if I clear the cache on Chrome) and the Netbeans IDE doesn't stop at any of the defined breakpoints. Is this to be expected? Does a Servlet get mangled in memory once it runs through the debugger once? Do I need to stop and restart/reattach the NetBeans debugger every time I want to debug the application? Is there something I'm doing wrong when using the debugger? Does this indicate a problem with the code I've written in my Servlet?
Thanks,
Jason Mazzotta
rjsang's point on the cache might be valid, and is worth investigating.
However, it might also be that something is breaking earlier than you expect, causing you to never even reach the break pointed lines.
I would suggest:
Look into liberally sprinkling your code with debug logging statements (using a good logging framework such as Log4J with SLF4j)
Throw more breakpoints at the problem - start with the very first line you expect to be hit from your request. And the go even higher/earlier, if possible.
Tail that Tomcat log (catalina.out) - you might spot something catastrophic happening there.
Good luck.