概述
public static boolean OutLogFile = true;// 输出log信息到文件
/** 输出log信息到文件中 */
public static String FileLog(String info)
{
if (OutLogFile)
{
String crashPath = "/sdcard/FileLog/Log/";
DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
String date = formatter.format(new Date());
DateFormat formatter2 = new SimpleDateFormat("HH:mm:ss");
String time = formatter2.format(new Date()) + " ";
String fileName = "log-" + date + ".txt";
info = "rn" + time + info;
try
{
if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED))
{
// String path = "/sdcard/com.hm.pay.demo/crash/";
File dir = new File(crashPath);
if (!dir.exists())
{
dir.mkdirs();
}
FileOutputStream fos = new FileOutputStream(crashPath + fileName, true);
fos.write(info.getBytes());
fos.close();
}
}
catch (Exception e)
{
Log.e(TAG, "an error occured while writing file log...", e);
}
return crashPath + fileName;
}
else return "";
}
最后
以上就是甜甜眼睛为你收集整理的android log日志输出到文件格式,安卓,输出log信息到文件中的全部内容,希望文章能够帮你解决android log日志输出到文件格式,安卓,输出log信息到文件中所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复