Source Code Cross Referenced for LoggerBase.java in  » Web-Server » Rimfaxe-Web-Server » org » apache » catalina » logger » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Web Server » Rimfaxe Web Server » org.apache.catalina.logger 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/logger/LoggerBase.java,v 1.5 2002/01/25 20:12:20 amyroh Exp $
003:         * $Revision: 1.5 $
004:         * $Date: 2002/01/25 20:12:20 $
005:         *
006:         * ====================================================================
007:         *
008:         * The Apache Software License, Version 1.1
009:         *
010:         * Copyright (c) 1999 The Apache Software Foundation.  All rights
011:         * reserved.
012:         *
013:         * Redistribution and use in source and binary forms, with or without
014:         * modification, are permitted provided that the following conditions
015:         * are met:
016:         *
017:         * 1. Redistributions of source code must retain the above copyright
018:         *    notice, this list of conditions and the following disclaimer.
019:         *
020:         * 2. Redistributions in binary form must reproduce the above copyright
021:         *    notice, this list of conditions and the following disclaimer in
022:         *    the documentation and/or other materials provided with the
023:         *    distribution.
024:         *
025:         * 3. The end-user documentation included with the redistribution, if
026:         *    any, must include the following acknowlegement:
027:         *       "This product includes software developed by the
028:         *        Apache Software Foundation (http://www.apache.org/)."
029:         *    Alternately, this acknowlegement may appear in the software itself,
030:         *    if and wherever such third-party acknowlegements normally appear.
031:         *
032:         * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
033:         *    Foundation" must not be used to endorse or promote products derived
034:         *    from this software without prior written permission. For written
035:         *    permission, please contact apache@apache.org.
036:         *
037:         * 5. Products derived from this software may not be called "Apache"
038:         *    nor may "Apache" appear in their names without prior written
039:         *    permission of the Apache Group.
040:         *
041:         * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
042:         * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
043:         * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
044:         * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
045:         * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
046:         * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
047:         * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
048:         * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
049:         * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
050:         * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
051:         * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
052:         * SUCH DAMAGE.
053:         * ====================================================================
054:         *
055:         * This software consists of voluntary contributions made by many
056:         * individuals on behalf of the Apache Software Foundation.  For more
057:         * information on the Apache Software Foundation, please see
058:         * <http://www.apache.org/>.
059:         *
060:         * [Additional notices, if required by prior licensing conditions]
061:         *
062:         */
063:
064:        package org.apache.catalina.logger;
065:
066:        import java.beans.PropertyChangeSupport;
067:        import java.beans.PropertyChangeListener;
068:        import java.io.CharArrayWriter;
069:        import java.io.PrintWriter;
070:        import javax.servlet.ServletException;
071:        import org.apache.catalina.Container;
072:        import org.apache.catalina.LifecycleException;
073:        import org.apache.catalina.Logger;
074:
075:        /**
076:         * Convenience base class for <b>Logger</b> implementations.  The only
077:         * method that must be implemented is <code>log(String msg)</code>, plus
078:         * any property setting and lifecycle methods required for configuration.
079:         *
080:         * @author Craig R. McClanahan
081:         * @version $Revision: 1.5 $ $Date: 2002/01/25 20:12:20 $
082:         */
083:
084:        public abstract class LoggerBase implements  Logger {
085:
086:            // ----------------------------------------------------- Instance Variables
087:
088:            /**
089:             * The Container with which this Logger has been associated.
090:             */
091:            protected Container container = null;
092:
093:            /**
094:             * The debugging detail level for this component.
095:             */
096:            protected int debug = 0;
097:
098:            /**
099:             * The descriptive information about this implementation.
100:             */
101:            protected static final String info = "org.apache.catalina.logger.LoggerBase/1.0";
102:
103:            /**
104:             * The property change support for this component.
105:             */
106:            protected PropertyChangeSupport support = new PropertyChangeSupport(
107:                    this );
108:
109:            /**
110:             * The verbosity level for above which log messages may be filtered.
111:             */
112:            protected int verbosity = ERROR;
113:
114:            // ------------------------------------------------------------- Properties
115:
116:            /**
117:             * Return the Container with which this Logger has been associated.
118:             */
119:            public Container getContainer() {
120:
121:                return (container);
122:
123:            }
124:
125:            /**
126:             * Set the Container with which this Logger has been associated.
127:             *
128:             * @param container The associated Container
129:             */
130:            public void setContainer(Container container) {
131:
132:                Container oldContainer = this .container;
133:                this .container = container;
134:                support.firePropertyChange("container", oldContainer,
135:                        this .container);
136:
137:            }
138:
139:            /**
140:             * Return the debugging detail level for this component.
141:             */
142:            public int getDebug() {
143:
144:                return (this .debug);
145:
146:            }
147:
148:            /**
149:             * Set the debugging detail level for this component.
150:             *
151:             * @param debug The new debugging detail level
152:             */
153:            public void setDebug(int debug) {
154:
155:                this .debug = debug;
156:
157:            }
158:
159:            /**
160:             * Return descriptive information about this Logger implementation and
161:             * the corresponding version number, in the format
162:             * <code>&lt;description&gt;/&lt;version&gt;</code>.
163:             */
164:            public String getInfo() {
165:
166:                return (info);
167:
168:            }
169:
170:            /**
171:             * Return the verbosity level of this logger.  Messages logged with a
172:             * higher verbosity than this level will be silently ignored.
173:             */
174:            public int getVerbosity() {
175:
176:                return (this .verbosity);
177:
178:            }
179:
180:            /**
181:             * Set the verbosity level of this logger.  Messages logged with a
182:             * higher verbosity than this level will be silently ignored.
183:             *
184:             * @param verbosity The new verbosity level
185:             */
186:            public void setVerbosity(int verbosity) {
187:
188:                this .verbosity = verbosity;
189:
190:            }
191:
192:            /**
193:             * Set the verbosity level of this logger.  Messages logged with a
194:             * higher verbosity than this level will be silently ignored.
195:             *
196:             * @param verbosityLevel The new verbosity level, as a string
197:             */
198:            public void setVerbosityLevel(String verbosity) {
199:
200:                if ("FATAL".equalsIgnoreCase(verbosity))
201:                    this .verbosity = FATAL;
202:                else if ("ERROR".equalsIgnoreCase(verbosity))
203:                    this .verbosity = ERROR;
204:                else if ("WARNING".equalsIgnoreCase(verbosity))
205:                    this .verbosity = WARNING;
206:                else if ("INFORMATION".equalsIgnoreCase(verbosity))
207:                    this .verbosity = INFORMATION;
208:                else if ("DEBUG".equalsIgnoreCase(verbosity))
209:                    this .verbosity = DEBUG;
210:
211:            }
212:
213:            // --------------------------------------------------------- Public Methods
214:
215:            /**
216:             * Add a property change listener to this component.
217:             *
218:             * @param listener The listener to add
219:             */
220:            public void addPropertyChangeListener(
221:                    PropertyChangeListener listener) {
222:
223:                support.addPropertyChangeListener(listener);
224:
225:            }
226:
227:            /**
228:             * Writes the specified message to a servlet log file, usually an event
229:             * log.  The name and type of the servlet log is specific to the
230:             * servlet container.  This message will be logged unconditionally.
231:             *
232:             * @param message A <code>String</code> specifying the message to be
233:             *  written to the log file
234:             */
235:            public abstract void log(String msg);
236:
237:            /**
238:             * Writes the specified exception, and message, to a servlet log file.
239:             * The implementation of this method should call
240:             * <code>log(msg, exception)</code> instead.  This method is deprecated
241:             * in the ServletContext interface, but not deprecated here to avoid
242:             * many useless compiler warnings.  This message will be logged
243:             * unconditionally.
244:             *
245:             * @param exception An <code>Exception</code> to be reported
246:             * @param msg The associated message string
247:             */
248:            public void log(Exception exception, String msg) {
249:
250:                log(msg, exception);
251:
252:            }
253:
254:            /**
255:             * Writes an explanatory message and a stack trace for a given
256:             * <code>Throwable</code> exception to the servlet log file.  The name
257:             * and type of the servlet log file is specific to the servlet container,
258:             * usually an event log.  This message will be logged unconditionally.
259:             *
260:             * @param msg A <code>String</code> that describes the error or
261:             *  exception
262:             * @param throwable The <code>Throwable</code> error or exception
263:             */
264:            public void log(String msg, Throwable throwable) {
265:
266:                CharArrayWriter buf = new CharArrayWriter();
267:                PrintWriter writer = new PrintWriter(buf);
268:                writer.println(msg);
269:                throwable.printStackTrace(writer);
270:                Throwable rootCause = null;
271:                if (throwable instanceof  LifecycleException)
272:                    rootCause = ((LifecycleException) throwable).getThrowable();
273:                else if (throwable instanceof  ServletException)
274:                    rootCause = ((ServletException) throwable).getRootCause();
275:                if (rootCause != null) {
276:                    writer.println("----- Root Cause -----");
277:                    rootCause.printStackTrace(writer);
278:                }
279:                log(buf.toString());
280:
281:            }
282:
283:            /**
284:             * Writes the specified message to the servlet log file, usually an event
285:             * log, if the logger is set to a verbosity level equal to or higher than
286:             * the specified value for this message.
287:             *
288:             * @param message A <code>String</code> specifying the message to be
289:             *  written to the log file
290:             * @param verbosity Verbosity level of this message
291:             */
292:            public void log(String message, int verbosity) {
293:
294:                if (this .verbosity >= verbosity)
295:                    log(message);
296:
297:            }
298:
299:            /**
300:             * Writes the specified message and exception to the servlet log file,
301:             * usually an event log, if the logger is set to a verbosity level equal
302:             * to or higher than the specified value for this message.
303:             *
304:             * @param message A <code>String</code> that describes the error or
305:             *  exception
306:             * @param throwable The <code>Throwable</code> error or exception
307:             * @param verbosity Verbosity level of this message
308:             */
309:            public void log(String message, Throwable throwable, int verbosity) {
310:
311:                if (this .verbosity >= verbosity)
312:                    log(message, throwable);
313:
314:            }
315:
316:            /**
317:             * Remove a property change listener from this component.
318:             *
319:             * @param listener The listener to remove
320:             */
321:            public void removePropertyChangeListener(
322:                    PropertyChangeListener listener) {
323:
324:                support.removePropertyChangeListener(listener);
325:
326:            }
327:
328:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.