To be more precise:
===========================================
import java.util.logging.ConsoleHandler;
import java.util.logging.Level;
import java.util.logging.LogRecord;
import java.util.logging.SimpleFormatter;
import java.util.logging.StreamHandler;
public class DualConsoleHandler extends StreamHandler {
private final ConsoleHandler stderrHandler = new ConsoleHandler();
public DualConsoleHandler() {
super(System.out, new SimpleFormatter());
}
@Override
public void publish(LogRecord record) {
if (record.getLevel().intValue() <= Level.INFO.intValue()) {
super.publish(record);
super.flush();
} else {
stderrHandler.publish(record);
stderrHandler.flush();
}
}
}
===========================================
import java.util.logging.Level;
import java.util.logging.Logger;
public class Application {
private static Logger logger =
Logger.getLogger(Application.class.getCanonicalName());
static {
logger.addHandler(new DualConsoleHandler());
logger.setUseParentHandlers(false);
}
public static void main(String[] args) {
logger.log(Level.INFO, "Does the output go to stout or
stderr?");
logger.log(Level.WARNING, "Does the output go to stout or
stderr?");
}
}
--
Alexander Kriegisch
http://scrum-master.de
Alexander Kriegisch schrieb am 11.11.2014 14:25:
> Maybe this helps:
> http://stackoverflow.com/questions/194165/how-do-i-change-java-logging-console-output-from-std-err-to-std-out
> http://stackoverflow.com/questions/2533227/how-can-i-disable-the-default-console-handler-while-using-the-java-logging-api/2533250#2533250
>
>> Yes, the output is going to stderr. I've confirmed that via some
>> debugging statements in the plugin.
>>
>> I haven't used native JUL before, but I'll investigate it. Any
>> pointers are much appreciated.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]