Why is exception.printStackTrace() considered bad practice?

Throwable.printStackTrace() writes the stack trace to System.err PrintStream. The System.err stream and the underlying standard “error” output stream of the JVM process can be redirected by invoking System.setErr() which changes the destination pointed to by System.err. or by redirecting the process’ error output stream. The error output stream may be redirected to a file/device whose … Read more

How to print the current Stack Trace in .NET without any exception?

Have a look at the System.Diagnostics namespace. Lots of goodies in there! System.Diagnostics.StackTrace t = new System.Diagnostics.StackTrace(); This is really good to have a poke around in to learn what’s going on under the hood. I’d recommend that you have a look into logging solutions (Such as NLog, log4net or the Microsoft patterns and practices … Read more

tech