Browse Source

e.printStackTrace改为logger.error

sunyj 9 years ago
parent
commit
5a1ac0e75e

+ 2 - 2
src/main/java/com/uas/report/schedule/service/impl/TaskServiceImpl.java

@@ -95,13 +95,13 @@ public class TaskServiceImpl implements TaskService {
 			fileWriter.flush();
 			logger.info("Saved task log:" + log.toJSONString() + " to " + logFilePath + "\n");
 		} catch (IOException e) {
-			e.printStackTrace();
+			logger.error("", e);
 		} finally {
 			if (fileWriter != null) {
 				try {
 					fileWriter.close();
 				} catch (IOException e) {
-					e.printStackTrace();
+					logger.error("", e);
 				}
 			}
 		}

+ 4 - 4
src/main/java/com/uas/report/service/impl/FileServiceImpl.java

@@ -168,7 +168,7 @@ public class FileServiceImpl implements FileService {
 			FileUtils.create(targetFile.getAbsolutePath(), file.getBytes());
 			return "成功上传文件至:" + targetFile.getPath();
 		} catch (IllegalStateException | IOException | ReportException e) {
-			e.printStackTrace();
+			logger.error("", e);
 			return "文件上传失败: " + fileName;
 		}
 	}
@@ -197,7 +197,7 @@ public class FileServiceImpl implements FileService {
 				FileUtils.create(targetFile.getAbsolutePath(), file.getBytes());
 				stringBuilder.append("成功上传文件至:");
 			} catch (IllegalStateException | IOException | ReportException e) {
-				e.printStackTrace();
+				logger.error("", e);
 				stringBuilder.append("上传文件失败:");
 			}
 			stringBuilder.append(targetFile.getPath()).append("\n");
@@ -285,7 +285,7 @@ public class FileServiceImpl implements FileService {
 				inputStream.read(data);
 				inputStream.close();
 			} catch (IOException e) {
-				e.printStackTrace();
+				logger.error("", e);
 			}
 		}
 		if (ArrayUtils.isEmpty(data)) {
@@ -306,7 +306,7 @@ public class FileServiceImpl implements FileService {
 			outputStream.flush();
 			outputStream.close();
 		} catch (IOException e) {
-			e.printStackTrace();
+			logger.error("", e);
 		}
 	}
 

+ 1 - 1
src/main/java/com/uas/report/service/impl/PrintServiceImpl.java

@@ -253,7 +253,7 @@ public class PrintServiceImpl implements PrintService {
 				}
 			}
 		} catch (JRException e) {
-			e.printStackTrace();
+			logger.error("", e);
 			throw new ReportException("编译报表模板失败: " + jrxmlFilePath + " " + e.getMessage()).setDetailedMessage(e);
 		}
 		return jasperFilePath;

+ 3 - 3
src/main/java/com/uas/report/util/MasterManager.java

@@ -142,21 +142,21 @@ public class MasterManager {
 				try {
 					resultSet.close();
 				} catch (SQLException e) {
-					e.printStackTrace();
+					logger.error("", e);
 				}
 			}
 			if (preparedStatement != null) {
 				try {
 					preparedStatement.close();
 				} catch (SQLException e) {
-					e.printStackTrace();
+					logger.error("", e);
 				}
 			}
 			if (connection != null) {
 				try {
 					connection.close();
 				} catch (SQLException e) {
-					e.printStackTrace();
+					logger.error("", e);
 				}
 			}
 		}

+ 6 - 1
src/main/java/com/uas/report/util/PathUtils.java

@@ -4,6 +4,9 @@ import java.io.File;
 import java.io.UnsupportedEncodingException;
 import java.net.URLDecoder;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 /**
  * 路径
  * 
@@ -12,6 +15,8 @@ import java.net.URLDecoder;
  */
 public class PathUtils {
 
+	private static Logger logger = LoggerFactory.getLogger(PathUtils.class);
+
 	private static String classPath;
 
 	private static String appPath;
@@ -57,7 +62,7 @@ public class PathUtils {
 		try {
 			strRealPath = URLDecoder.decode(strRealPath, "UTF-8");
 		} catch (UnsupportedEncodingException e) {
-			e.printStackTrace();
+			logger.error("", e);
 		}
 		File objFile = new File(strRealPath);
 		classPath = objFile.getParent() + File.separator;

+ 5 - 5
src/main/java/com/uas/report/util/ZipUtils.java

@@ -63,7 +63,7 @@ public class ZipUtils {
 			zipData = outputStream.toByteArray();
 			outputStream.close();
 		} catch (IOException e) {
-			e.printStackTrace();
+			logger.error("", e);
 		}
 		return zipData;
 	}
@@ -97,7 +97,7 @@ public class ZipUtils {
 			zipOutputStream.close();
 			logger.info("Zip finished to... " + zipFilePath);
 		} catch (IOException e) {
-			e.printStackTrace();
+			logger.error("", e);
 		}
 	}
 
@@ -136,7 +136,7 @@ public class ZipUtils {
 				logger.info("Ziped from... " + file.getPath());
 			}
 		} catch (IOException e) {
-			e.printStackTrace();
+			logger.error("", e);
 		}
 	}
 
@@ -175,7 +175,7 @@ public class ZipUtils {
 			}
 			zipInputStream.close();
 		} catch (IOException e) {
-			e.printStackTrace();
+			logger.error("", e);
 		}
 		logger.info("Unzip done");
 	}
@@ -231,7 +231,7 @@ public class ZipUtils {
 			}
 			zipFile.close();
 		} catch (IOException e) {
-			e.printStackTrace();
+			logger.error("", e);
 		}
 		logger.info("Unzip finished from... " + zipFilePath);
 	}