1 17 18 package com.finalist.util.log; 19 20 25 public class LogConfig { 26 27 28 private String logFile = "finalist%g.log"; 29 30 31 private boolean append = true; 32 33 34 private int maxBackupIndex = 1; 35 36 37 private int maxFileSize = 50; 38 39 40 private int showNumberOfLastPackages = 0; 41 42 43 private String datePattern = "yyyy-MM-dd HH:mm:ss,SSS"; 44 45 46 private String messageSeparator = "-"; 47 48 49 private String logLevel = "INFO"; 50 51 52 64 public LogConfig(String logFile, 65 boolean append, 66 int maxBackupIndex, 67 int maxFileSize, 68 int showNumberOfLastPackages, 69 String datePattern, 70 String messageSeparator, 71 String logLevel) { 72 if ((logFile != null) && (!logFile.equals(""))) { 73 this.logFile = logFile; 74 } 75 this.append = append; 76 if (maxBackupIndex > 0) { 77 this.maxBackupIndex = maxBackupIndex; 78 } 79 if (maxFileSize > 0) { 80 this.maxFileSize = maxFileSize; 81 } 82 if (showNumberOfLastPackages > -1) { 83 this.showNumberOfLastPackages = showNumberOfLastPackages; 84 } 85 if ((datePattern != null) && (!datePattern.equals(""))) { 86 this.datePattern = datePattern; 87 } 88 if ((messageSeparator != null) && (!messageSeparator.equals(""))) { 89 this.messageSeparator = messageSeparator; 90 } 91 if ((logLevel != null) && (!logLevel.equals(""))) { 92 this.logLevel = logLevel; 93 } 94 } 95 96 97 101 public String getLogFile() { 102 return this.logFile; 103 } 104 105 106 110 public boolean isAppendable() { 111 return this.append; 112 } 113 114 115 119 public int getMaxBackupIndex() { 120 return this.maxBackupIndex; 121 } 122 123 124 128 public int getMaxFileSize() { 129 return this.maxFileSize; 130 } 131 132 133 137 public int getShowNumberOfLastPackages() { 138 return this.showNumberOfLastPackages; 139 } 140 141 142 146 public String getDatePattern() { 147 return this.datePattern; 148 } 149 150 151 155 public String getMessageSeparator() { 156 return this.messageSeparator; 157 } 158 159 160 164 public String getLogLevel() { 165 return this.logLevel; 166 } 167 168 169 173 public String toString() { 174 return "[logFile=" + this.logFile + "]" + 175 ", [append=" + this.append + "]" + 176 ", [maxBackupIndex=" + this.maxBackupIndex + "]" + 177 ", [maxFileSize=" + this.maxFileSize + "]" + 178 ", [showNumberOfLastPackages=" + this.showNumberOfLastPackages + "]" + 179 ", [datePattern=" + this.datePattern + "]" + 180 ", [messageSeparator=" + this.messageSeparator + "]" + 181 ", [logLevel=" + this.logLevel + "]"; 182 } 183 } | Popular Tags |