I\'m using the standard ConsoleHandler from java.util.logging and by default the console output is directed to the error stream (i.e. System.
Step 1: Set parent handlers to false.
log.setUseParentHandlers(false);
Step 2: Add a handler that writes to System.out
log.addHandler(new StreamHandler(System.out, new SimpleFormatter()));
Thats it..
import java.io.IOException;
import java.util.logging.Logger;
import java.util.logging.SimpleFormatter;
import java.util.logging.StreamHandler;
public class App {
static final Logger log = Logger.getLogger("com.sample.app.App");
static void processData() {
log.info("Started Processing Data");
log.info("Finished processing data");
}
public static void main(String args[]) throws IOException {
log.setUseParentHandlers(false);
log.addHandler(new StreamHandler(System.out, new SimpleFormatter()));
processData();
}
}