0
我有以下代碼:重定向System.out.err不起作用
private void replaceStdIo(SocketChannel socketChannel) throws IOException {
socketChannel.configureBlocking(blockingMode);
InputStream in = new RedirectorInputStream();
PrintStream out = new PrintStream(new RedirectorOutputStream(), false, charsetEncoding);
System.setIn(in);
System.setErr(out);
System.setOut(out);
}
這是一個更大的Telnet類,我用它來獲取信息從我的服務器的一部分。目前的問題是我有一臺記錄器。我想將記錄器的所有內容輸出到Telnet控制檯,但只有System.out.print可以工作。 System.err也應該工作,但由於某種原因它不是?
這是IDE的控制檯輸出:
14:06:42:0723.: From ConsoleIn.java -> Found the Commandinput FINEST in
setDebugLevel(FINEST)
14:06:42:0725.: From Debug.java -> Set debugLevel to FINEST
但這並沒有得到在Telnet控制檯打印出來的PC,只能用System.out的一切上。有誰知道爲什麼?