In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly introduces java e.printStackTrace() will not be output to the console, the text is very detailed, has a certain reference value, interested friends must read!
Java e.printStackTrace() will only output to the console? No output to log files? Do I need logger.error(e) to output to a log file? Do you need logger.error(e) or logger.error(e.printStackTrace())?
e.printStackTrace() will only output to the console
tomcat will output to catalina.out
Do not log with e.pringStackTrace()
log.error("error message",e) if the call stack is input; log.error("error message") if the call stack is not output;
suddenly smiled
e.pringStackTrace() is a call to System.err.println(). It should be used like this.
try{
//doSomething
}catch(IllegalAccessExceptione){
logger.error("Error message:",e);
}
e.printStackTrace() causes lockup?
Notice the lower right corner, the red box. What is this memory? Non-heaps! So, on the left is code cache memory, and on the right is string pool, constants, primitive data memory. And then what? It's full. What's the reason? e.printStackTrace()!
What about full consequences? The entire web service, after access, did not respond, as if the card died.
Look at how many web request threads are stuck at this step of printing! Why? To print string output to the console, you need space in the memory block where your string constant pool is located. However, because the string generated by the e.printStackTrace() statement records stack information, it is too long and memory is full! Note the above code statement: line 4208!
Look at Figure 3:
There's nothing wrong with it. There's nothing wrong with it. That's what this code does! Of course, I admit that there is something wrong with the code being tried, causing many calls to throw exceptions.
So let's look at the whole story:
A large number of requests to access this interface in a short time-> code itself has problems, in many cases throw exceptions->e.printStackTrace() to print exceptions to the console-> generate error stack strings to the string pool memory space-> this memory space is suddenly full-> the thread that started producing strings in this memory space is not fully produced, there is no space-> a large number of threads produce strings halfway, Wait here (wait for memory to continue)-> wait for each other, wait for memory, lock, the whole application hangs.
The above is "java e.printStackTrace() will not output to the console" all the content of this article, thank you for reading! Hope to share the content to help everyone, more relevant knowledge, welcome to pay attention to the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.