c082f519aa189cdf6a4a201082011b8c9c68875b.svn-base 2.9 KB
package com.espeed.yxy.tool;

import java.io.File;
import java.io.FileWriter;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * 程序名称:    	EspeedMail_时速邮箱
 * 程序版本:    	V1.0
 * 作    者:    	深圳市科飞时速网络技术有限公司(0755-88843776)
 * 版权所有:    	深圳市科飞时速网络技术有限公司
 * 技术支持:    	Tech@21gmail.com
 * 单元名称:    日志记录工具类
 * 开始时间:    	2013.11.18
 * 程 序 员:    	谢勇
 * 最后修改:    
 * 备    注:		如需修改请通知程序员    
 */
public class LogsTool{
	
	/**邮件发送日志*/
	public static void sendLogs(String domain,String username,String value){
		try {
			//以当前时间为日志文件名
			SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
			String nowDate=sdf.format(new Date());
			//发生的时间
			SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
			String nowDates=sdf1.format(new Date());
			//组建路径
			String savePath="D:/yxysendlog/"+domain+"/"+username;
			File files = new File(savePath);
			if (!files.exists()) {
				files.mkdirs();
			}
			
			//写入文件
			FileWriter w = new FileWriter(savePath+"/"+nowDate+".txt", true);
			w.write(nowDates+":   "+value+"\r\n");
			w.close();
		} catch (Exception e) {
			e.printStackTrace();
			System.out.println("日志记录异常");
		}
	}
	
	/**营销异常日志*/
	public static void erroLogs(String value){
		try {
			//以当前时间为日志文件名
			SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
			String nowDate=sdf.format(new Date());
			//发生的时间
			SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
			String nowDates=sdf1.format(new Date());
			//组建路径
			String savePath="D:/yxysenderro/";
			File files = new File(savePath);
			if (!files.exists()) {
				files.mkdirs();
			}
			//写入文件
			FileWriter w = new FileWriter(savePath+nowDate+".txt", true);
			w.write(nowDates+":   "+value+"\r\n");
			w.close();
		} catch (Exception e) {
			e.printStackTrace();
			System.out.println("日志记录异常");
		}
	}
	
	/**执行计划异常日志*/
	public static void marketPlanLogs(String value){
		try {
			//以当前时间为日志文件名
			SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
			String nowDate=sdf.format(new Date());
			//发生的时间
			SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
			String nowDates=sdf1.format(new Date());
			//组建路径
			String savePath="D:/yxymarketplanerro/";
			File files = new File(savePath);
			if (!files.exists()) {
				files.mkdirs();
			}
			//写入文件
			FileWriter w = new FileWriter(savePath+nowDate+".txt", true);
			w.write(nowDates+":   "+value+"\r\n");
			w.close();
		} catch (Exception e) {
			e.printStackTrace();
			System.out.println("日志记录异常");
		}
	}
	
	public static void main(String[] args) {
		LogsTool.erroLogs("测试");
	}
}