KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > finalist > util > log > LogConfig


1 /* Copyright (C) 2003 Finalist IT Group
2  *
3  * This file is part of JAG - the Java J2EE Application Generator
4  *
5  * JAG is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  * JAG is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  * You should have received a copy of the GNU General Public License
14  * along with JAG; if not, write to the Free Software
15  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16  */

17
18 package com.finalist.util.log;
19
20 /**
21  * Value object with log settings
22  * @author Ronald Kramp - Finalist IT Group
23  * @version $Revision: 1.1 $, $Date: 2004/11/12 14:06:44 $
24  */

25 public class LogConfig {
26
27    /** the logfile to log to */
28    private String JavaDoc logFile = "finalist%g.log";
29
30    /** append to the logfile */
31    private boolean append = true;
32
33    /** maximum number of logfiles to create */
34    private int maxBackupIndex = 1;
35
36    /** maxfilesize for each created logfile */
37    private int maxFileSize = 50;
38
39    /** the number of packages to show for a class */
40    private int showNumberOfLastPackages = 0;
41
42    /** the datepattern to log */
43    private String JavaDoc datePattern = "yyyy-MM-dd HH:mm:ss,SSS";
44
45    /** the messagespearator */
46    private String JavaDoc messageSeparator = "-";
47
48    /** the loglevel for logging certain messages */
49    private String JavaDoc logLevel = "INFO";
50
51
52    /**
53     * Constrcutor for making a LogConfig
54     * All settings for a appender
55     * @param logFile the name of the logfile, default finalist%g.log
56     * @param append default true
57     * @param maxBackupIndex the number of files to create, must be greater than 0, default 1
58     * @param maxFileSize the size of a log file in megabytes, must be greater than 0, default 50
59     * @param showNumberOfLastPackages the number of pacakges of a class to show, cannot be negative, default 0
60     * @param datePattern the date to log, default yyyy-MM-dd HH:mm:ss,SSS
61     * @param messageSeparator default -
62     * @param logLevel default INFO
63     */

64    public LogConfig(String JavaDoc logFile,
65          boolean append,
66          int maxBackupIndex,
67          int maxFileSize,
68          int showNumberOfLastPackages,
69          String JavaDoc datePattern,
70          String JavaDoc messageSeparator,
71          String JavaDoc 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    /**
98     * Get the name of the logfile
99     * @return String, the name of the log file
100     */

101    public String JavaDoc getLogFile() {
102       return this.logFile;
103    }
104
105
106    /**
107     * Check to see if the logfile is appendable
108     * @return boolean, logfile is appendable
109     */

110    public boolean isAppendable() {
111       return this.append;
112    }
113
114
115    /**
116     * Get the maxBackupIndex
117     * @return int, the maxBackupIndex
118     */

119    public int getMaxBackupIndex() {
120       return this.maxBackupIndex;
121    }
122
123
124    /**
125     * Get the maxFileSize
126     * @return int, maxFileSize
127     */

128    public int getMaxFileSize() {
129       return this.maxFileSize;
130    }
131
132
133    /**
134     * Get the showNumberOfLastPackages
135     * @return int, the showNumberOfLastPackages
136     */

137    public int getShowNumberOfLastPackages() {
138       return this.showNumberOfLastPackages;
139    }
140
141
142    /**
143     * Get the datePattern
144     * @return String, the datePattern
145     */

146    public String JavaDoc getDatePattern() {
147       return this.datePattern;
148    }
149
150
151    /**
152     * Get the messageSeparator
153     * @return String, the messageSeparator
154     */

155    public String JavaDoc getMessageSeparator() {
156       return this.messageSeparator;
157    }
158
159
160    /**
161     * Get the logLevel
162     * @return String, the logLevel
163     */

164    public String JavaDoc getLogLevel() {
165       return this.logLevel;
166    }
167
168
169    /**
170     * returning the string with all values
171     * @return String, all values as a String
172     */

173    public String JavaDoc 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