Java starts an external program containing log4cxx, causing the program to be suspended

Source: Internet
Author: User

I have been tossing for this thing for a day today!

I use the middleware written in Java to start a sub-process based on the user's needs. This process is written in C ++ and is easy to use log4cxx to record logs for analysis. This process runs independently from the control terminal without any problems. However, once the Java promoter process is used to start the process, the sub-process will not be blocked as soon as it is started, then, the sub-process can be executed smoothly, which may take several minutes to two hours.

The first time I encountered such a problem, it was very strange. After repeated tests and the omnipotent google help, I found the reason why Java called external programs to suspend. log4cxx was originally the culprit, because it redirects a large amount of log information to the console, because the Java Process is not clearedProgramAs a result, the program remains waiting.

There are two solutions to this problem:

  1. As mentioned above, when Java starts an external program and causes thread blocking, you can consider using two threads to clear the two input streams obtained by process at the same time;
  2. You can directly redirect log4cxx to the console to cancel the log message, which can be achieved through the log4cxx configuration file.

After the problem is solved, the world becomes beautiful again!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.