您的位置:首页 > 运维架构 > Tomcat

解惑tomcat如何将标准输出保存到文件——重定向System.out

2016-01-13 15:07 686 查看
看代码就懂:
package com.xs.test;

import java.io.FileOutputStream;
import java.io.PrintStream;

public class Test {
public static void main(String[] args) throws Exception {
String outPath = "C:\\out.log";
System.setOut(new PrintStream(new FileOutputStream(outPath, true)));
System.out.println("Hello world!");
}
}
程序中所有的标准输出就保存到文件了。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: