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

来源:互联网 发布:财务公司待遇 知乎 编辑:程序博客网 时间:2024/05/21 19:31

看代码就懂:

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!");}}
程序中所有的标准输出就保存到文件了。



0 0
原创粉丝点击