001: /* Copyright (C) 2003 Finalist IT Group
002: *
003: * This file is part of JAG - the Java J2EE Application Generator
004: *
005: * JAG is free software; you can redistribute it and/or modify
006: * it under the terms of the GNU General Public License as published by
007: * the Free Software Foundation; either version 2 of the License, or
008: * (at your option) any later version.
009: * JAG is distributed in the hope that it will be useful,
010: * but WITHOUT ANY WARRANTY; without even the implied warranty of
011: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
012: * GNU General Public License for more details.
013: * You should have received a copy of the GNU General Public License
014: * along with JAG; if not, write to the Free Software
015: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
016: */
017:
018: package com.finalist.util.log;
019:
020: /**
021: * Value object with log settings
022: * @author Ronald Kramp - Finalist IT Group
023: * @version $Revision: 1.1 $, $Date: 2004/11/12 14:06:44 $
024: */
025: public class LogConfig {
026:
027: /** the logfile to log to */
028: private String logFile = "finalist%g.log";
029:
030: /** append to the logfile */
031: private boolean append = true;
032:
033: /** maximum number of logfiles to create */
034: private int maxBackupIndex = 1;
035:
036: /** maxfilesize for each created logfile */
037: private int maxFileSize = 50;
038:
039: /** the number of packages to show for a class */
040: private int showNumberOfLastPackages = 0;
041:
042: /** the datepattern to log */
043: private String datePattern = "yyyy-MM-dd HH:mm:ss,SSS";
044:
045: /** the messagespearator */
046: private String messageSeparator = "-";
047:
048: /** the loglevel for logging certain messages */
049: private String logLevel = "INFO";
050:
051: /**
052: * Constrcutor for making a LogConfig
053: * All settings for a appender
054: * @param logFile the name of the logfile, default finalist%g.log
055: * @param append default true
056: * @param maxBackupIndex the number of files to create, must be greater than 0, default 1
057: * @param maxFileSize the size of a log file in megabytes, must be greater than 0, default 50
058: * @param showNumberOfLastPackages the number of pacakges of a class to show, cannot be negative, default 0
059: * @param datePattern the date to log, default yyyy-MM-dd HH:mm:ss,SSS
060: * @param messageSeparator default -
061: * @param logLevel default INFO
062: */
063: public LogConfig(String logFile, boolean append,
064: int maxBackupIndex, int maxFileSize,
065: int showNumberOfLastPackages, String datePattern,
066: String messageSeparator, String logLevel) {
067: if ((logFile != null) && (!logFile.equals(""))) {
068: this .logFile = logFile;
069: }
070: this .append = append;
071: if (maxBackupIndex > 0) {
072: this .maxBackupIndex = maxBackupIndex;
073: }
074: if (maxFileSize > 0) {
075: this .maxFileSize = maxFileSize;
076: }
077: if (showNumberOfLastPackages > -1) {
078: this .showNumberOfLastPackages = showNumberOfLastPackages;
079: }
080: if ((datePattern != null) && (!datePattern.equals(""))) {
081: this .datePattern = datePattern;
082: }
083: if ((messageSeparator != null)
084: && (!messageSeparator.equals(""))) {
085: this .messageSeparator = messageSeparator;
086: }
087: if ((logLevel != null) && (!logLevel.equals(""))) {
088: this .logLevel = logLevel;
089: }
090: }
091:
092: /**
093: * Get the name of the logfile
094: * @return String, the name of the log file
095: */
096: public String getLogFile() {
097: return this .logFile;
098: }
099:
100: /**
101: * Check to see if the logfile is appendable
102: * @return boolean, logfile is appendable
103: */
104: public boolean isAppendable() {
105: return this .append;
106: }
107:
108: /**
109: * Get the maxBackupIndex
110: * @return int, the maxBackupIndex
111: */
112: public int getMaxBackupIndex() {
113: return this .maxBackupIndex;
114: }
115:
116: /**
117: * Get the maxFileSize
118: * @return int, maxFileSize
119: */
120: public int getMaxFileSize() {
121: return this .maxFileSize;
122: }
123:
124: /**
125: * Get the showNumberOfLastPackages
126: * @return int, the showNumberOfLastPackages
127: */
128: public int getShowNumberOfLastPackages() {
129: return this .showNumberOfLastPackages;
130: }
131:
132: /**
133: * Get the datePattern
134: * @return String, the datePattern
135: */
136: public String getDatePattern() {
137: return this .datePattern;
138: }
139:
140: /**
141: * Get the messageSeparator
142: * @return String, the messageSeparator
143: */
144: public String getMessageSeparator() {
145: return this .messageSeparator;
146: }
147:
148: /**
149: * Get the logLevel
150: * @return String, the logLevel
151: */
152: public String getLogLevel() {
153: return this .logLevel;
154: }
155:
156: /**
157: * returning the string with all values
158: * @return String, all values as a String
159: */
160: public String toString() {
161: return "[logFile=" + this .logFile + "]" + ", [append="
162: + this .append + "]" + ", [maxBackupIndex="
163: + this .maxBackupIndex + "]" + ", [maxFileSize="
164: + this .maxFileSize + "]"
165: + ", [showNumberOfLastPackages="
166: + this .showNumberOfLastPackages + "]"
167: + ", [datePattern=" + this .datePattern + "]"
168: + ", [messageSeparator=" + this .messageSeparator + "]"
169: + ", [logLevel=" + this .logLevel + "]";
170: }
171: }
|