本文介绍了如何附加日志文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在每次执行时追加日志文件。
如何使用以下代码执行此操作...
我尝试过:
我正在使用此代码编写日志文件.....
I want to append the log file on each time of execution.
How to do this using fallowing code...
What I have tried:
I'm writing log file using this code.....
static String fileTempPath= System.getProperty("java.io.tmpdir");
static Date ch=new java.sql.Date(System.currentTimeMillis());
static File tempFile=new File(fileTempPath+"PurgeLog"+ch + ".log");
static PrintWriter out;
public static void main(String[] args)
{
out=new PrintWriter(tempFile);
out.println("main started:")
out.println("heloooo:")
out.close();
}
}
推荐答案
FileWriter out = new FileWriter(fileTempPath+"PurgeLog"+ch + ".log", true);
out.write("main started:\n");
out.write("heloooo:\n");
out.close();
这篇关于如何附加日志文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!