DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=35020>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND·
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=35020

           Summary: Using Logger and Runtime.exec() causes Explorer to run
                    at 100% CPU
           Product: Log4j
           Version: unspecified
          Platform: PC
        OS/Version: Windows XP
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Other
        AssignedTo: log4j-dev@logging.apache.org
        ReportedBy: [EMAIL PROTECTED]


I've ran into this interesting bug: When executing a system command through
Runtime.getRuntime.exec(COMMAND); and using Log4j, Explorer.exe suddenly
requires 100% CPU for a while. 

I couldn't find out within the JAR what version of Log4j I'm using.

Platform: Windows XP Professional sp 2
Java: Java version 1.4.2_06


--------   code   --------
// Code usage: java BugTester log|nolog

import java.io.BufferedReader;
import java.io.InputStreamReader;

import org.apache.log4j.Logger;

public class BugTester {

        // exchange this for any valid command on your platform
        protected static String CMD = "net time";

        static Logger log = Logger.getLogger(BugTester.class);

        public static void main(String[] args) {
                try {
                        if (args.length > 0) {
                                if ("log".equalsIgnoreCase(args[0])) {
                                        log.debug("Begin.");
                                        Process process = 
Runtime.getRuntime().exec(CMD);
                                        BufferedReader in = new 
BufferedReader(new
InputStreamReader(process.getInputStream()));
                                        BufferedReader err = new 
BufferedReader(new
InputStreamReader(process.getErrorStream()));
                                        process.waitFor();
                                        
                                        // flush the out/err
                                        String line = null;
                                        while ((line = in.readLine()) != null) {
                                                log.debug(line);
                                        }
                                        while ((line = err.readLine()) != null) 
{
                                                log.error(line);
                                        }
                                        
                                        log.debug("The end.");
                                        System.exit(0);
                                        
                                } else if ("nolog".equalsIgnoreCase(args[0])) {
                                        
                                        System.out.println("Begin.");
                                        Process process = 
Runtime.getRuntime().exec(CMD);
                                        BufferedReader in = new 
BufferedReader(new
InputStreamReader(process.getInputStream()));
                                        BufferedReader err = new 
BufferedReader(new
InputStreamReader(process.getErrorStream()));
                                        process.waitFor();
                                        
                                        // flush the out/err
                                        String line = null;
                                        while ((line = in.readLine()) != null) {
                                                System.out.println(line);
                                        }
                                        while ((line = err.readLine()) != null) 
{
                                                System.err.println(line);
                                        }
                                        
                                        System.out.println("The end.");
                                        System.exit(0);
                                }
                        }
                        
                } catch (Exception e) {
                        log.error("Crash.");
                }
                System.out.println("Usage: BugTester log|nolog");
        }
}


-------- end code --------

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to