Reprinted from: http://kb.cnblogs.com/page/162988/
Stack trace)
I'm curious about this problem. I 've observed what happens when these stack trace information is collected. This is common. You will record an exception and its stack trace information to find out what the problem is.
So I modifiedCodeTo obtain the stack trace information of an exception. The situation has changed significantly. Obtaining abnormal stack tracing information is 10 times more performance pressure than simply capturing and throwing them. Therefore, the stack trace information helps us understand what went wrong or even why, but it also brings performance penalties.
This usually has a huge impact on performance, because we don't just face a stack trace. In most cases, an exception throw-capture occurs at multiple levels. Let's take a look at a simple web service connection server example. First, exceptions that fail to be connected are generated at the Java class library. The failure of the client will be captured by the framework, and some service logic calls at the application layer will throw an exception. Now, three types of stack trace information are collected.
In most cases, you can view these log files and application output information. Recording these long stack information can also bring performance impact. If you regularly view your log files, you will usually study them and respond to the problem-this is what you want to do, isn't it ?; -)
Sometimes I can see more serious performance problems caused by incorrect log writing. Instead of calling log. isxxenabled () to check whether a log-level log behavior is open, developers directly call the logging method. When you do this, the log code always returns abnormal stack trace information during execution. However, because the log level settings are too low, you may never see this information, and you may not know what happened. First, check the log record level. This should be considered a basic habit, which will avoid unnecessary objects.