[logback-user] logback console appender slow on windows xp

Peter Kullmann p.kullmann at arenae.ch
Tue Dec 20 18:34:11 CET 2011


Hi, 

we had a problem with the performance of our application and it boiled down to very bad performance of the console appender when there is no console (in particular on windows xp). 

You can see the whole context of the issue here: http://www.eclipse.org/forums/index.php/m/768740/#msg_768740

Here's the conclusion and the code for my experiments:


package testlogback;

import java.io.FileWriter;
import java.io.IOException;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class Main {
    public static void main(String[] args) throws IOException {
        Logger logger = LoggerFactory
                .getLogger("chapters.introduction.HelloWorld1");
        long start = System.currentTimeMillis();
        for (int i = 0; i < 10000; i++) {
            logger.debug("Hello world.");
        }
        long end = System.currentTimeMillis();

        FileWriter fileWriter = new FileWriter("logbacktest.out");
        fileWriter.write("Time: " + (end - start) + "\n");
        fileWriter.close();
        System.out.println("Time: " + (end - start));
    }
}


On my windows box it prints out "Time: 140" when started as "java -jar testlogback.jar". If I start "javaw -jar testlogback.jar" it uses 100% CPU for about 20 seconds (for effectively doing nothing). This is the case for Sun ire 6 and 7 on windows xp.

On windows 7 the situation is better: javaw uses only about 7 seconds (which is still too much, I guess).

Best regards,
Peter




More information about the Logback-user mailing list