📄 mail-2001-03-13t0646
字号:
Copied fromhttp://www.mail-archive.com/log4j-user@jakarta.apache.org/msg00445.html--------------------------------------------------------------------------------RE: diverting System.stderr/stdout into log4j--------------------------------------------------------------------------------From: Michael Smith Subject: RE: diverting System.stderr/stdout into log4j Date: Tue, 13 Mar 2001 06:46:04 -0800 --------------------------------------------------------------------------------There is another way!In LogLog, completely ignore System.err. Instead, use the following to getthe standard error stream:PrintStream err = new PrintStream(new FileOutputStream(FileDescriptor.err));When you use System.setErr, it changes System.err, but notFileDescriptor.err, which maintains a descriptor for the original errorstream.michaelFor a sample program to test this, see below:import java.io.*;public class Stderr { public static void main(String[] args) { // create a print stream to represent a redirect PrintStream nonStandardErr = new PrintStream(new ByteArrayOutputStream()); // Redirect standard out and standard err System.setOut(nonStandardErr); System.setErr(nonStandardErr); // attempt to print something System.err.println("You should *not* see this on the console!"); // the stuff that would appear in LogLog PrintStream logLogOut = new PrintStream(new FileOutputStream(FileDescriptor.err)); // attempt to print something logLogOut.println("You *should* see this on the console!"); }}> -----Original Message-----> From: Ceki G黮c
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -