mail-2001-03-13t0646
来自「实现在电脑平台上控制短信modem或手机进行通讯的jar包和相关实例」· 代码 · 共 60 行
TXT
60 行
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 + =
减小字号Ctrl + -
显示快捷键?