Intellij println only if in debugger?
Answered
The .Net framework has a clever feature System.Diagnostics.Debug.WriteLine() that will only output when running in the debugger. Is there an equivalent feature in Java/IntelliJ? If not, is there a way to tell that I'm running in the debugger so that I can write my own equivalent?
Please sign in to leave a comment.
- you can use frameworks like SLF4J or Log4j to control the messaging, check this as an example
- with logs adjusted, you can view them in a separate tab when running in debug
- additionally, you can also check "Show console when a message is printed into stdout/stderr" in the same menu in the link above