在你的程序开头的地方加一个static域,
static {
try {
out = new PrintStream(new FileOutputStream(fileName, true), true);
} catch (Exception e) {
e.printStackTrace();
}
}然后在你想写log的地方,用:out.println("What you want to log!");就可以了!
对了,上面fileName就是你想要得log文件名,要有路径!
static {
try {
out = new PrintStream(new FileOutputStream(fileName, true), true);
} catch (Exception e) {
e.printStackTrace();
}
}然后在你想写log的地方,用:out.println("What you want to log!");就可以了!
对了,上面fileName就是你想要得log文件名,要有路径!
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货