001: /*
002: * Copyright (c) 1998-2008 Caucho Technology -- all rights reserved
003: *
004: * This file is part of Resin(R) Open Source
005: *
006: * Each copy or derived work must preserve the copyright notice and this
007: * notice unmodified.
008: *
009: * Resin Open Source is free software; you can redistribute it and/or modify
010: * it under the terms of the GNU General Public License as published by
011: * the Free Software Foundation; either version 2 of the License, or
012: * (at your option) any later version.
013: *
014: * Resin Open Source is distributed in the hope that it will be useful,
015: * but WITHOUT ANY WARRANTY; without even the implied warranty of
016: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
017: * of NON-INFRINGEMENT. See the GNU General Public License for more
018: * details.
019: *
020: * You should have received a copy of the GNU General Public License
021: * along with Resin Open Source; if not, write to the
022: * Free SoftwareFoundation, Inc.
023: * 59 Temple Place, Suite 330
024: * Boston, MA 02111-1307 USA
025: *
026: * @author Scott Ferguson
027: */
028:
029: package com.caucho.http.log;
030:
031: import com.caucho.log.Log;
032: import com.caucho.vfs.WriteStream;
033:
034: import javax.servlet.ServletContext;
035: import javax.servlet.ServletException;
036: import javax.servlet.http.HttpServletRequest;
037: import javax.servlet.http.HttpServletResponse;
038: import java.io.IOException;
039: import java.util.logging.Logger;
040:
041: /**
042: * Represents an log of every error log request to the server.
043: */
044: abstract public class AbstractErrorLog {
045: protected static final Logger log = Log
046: .open(AbstractErrorLog.class);
047:
048: protected WriteStream logStream;
049:
050: /**
051: * Returns the access-log's path.
052: */
053: public WriteStream getLogStream() {
054: return logStream;
055: }
056:
057: /**
058: * Sets the access-log's path.
059: */
060: public void setLogStream(WriteStream os) {
061: this .logStream = os;
062: }
063:
064: /**
065: * Initialize the log.
066: */
067: public void init() throws ServletException, IOException {
068: }
069:
070: /**
071: * Logs an error.
072: *
073: * @param message the error message
074: * @param request the servlet request
075: * @param response the servlet response
076: * @param application the servlet context
077: */
078: public abstract void log(String message,
079: HttpServletRequest request, HttpServletResponse response,
080: ServletContext application) throws IOException;
081:
082: /**
083: * Logs an error.
084: *
085: * @param message the error message
086: * @param exception the thrown exception
087: * @param request the servlet request
088: * @param response the servlet response
089: * @param application the servlet context
090: */
091: public abstract void log(String message, Throwable exception,
092: HttpServletRequest request, HttpServletResponse response,
093: ServletContext application) throws IOException;
094:
095: /**
096: * Cleanup the log.
097: */
098: public void destroy() throws IOException {
099: }
100: }
|