KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > log4j > spi > ErrorHandler


1 /*
2  * Copyright 1999-2005 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16
17 package org.apache.log4j.spi;
18
19 import org.apache.log4j.Appender;
20 import org.apache.log4j.Logger;
21
22
23 /**
24    Appenders may delegate their error handling to
25    <code>ErrorHandlers</code>.
26
27    <p>Error handling is a particularly tedious to get right because by
28    definition errors are hard to predict and to reproduce.
29
30
31    <p>Please take the time to contact the author in case you discover
32    that errors are not properly handled. You are most welcome to
33    suggest new error handling policies or criticize existing policies.
34
35
36    @author Ceki G&uuml;lc&uuml;
37    
38 */

39 public interface ErrorHandler extends OptionHandler {
40
41   /**
42      Add a reference to a logger to which the failing appender might
43      be attached to. The failing appender will be searched and
44      replaced only in the loggers you add through this method.
45
46      @param logger One of the loggers that will be searched for the failing
47      appender in view of replacement.
48      
49      @since 1.2 */

50   void setLogger(Logger logger);
51
52
53   /**
54      Equivalent to the {@link #error(String, Exception, int,
55      LoggingEvent event)} with the the event parameteter set to
56      <code>null</code>.
57      
58   */

59   void error(String JavaDoc message, Exception JavaDoc e, int errorCode);
60
61   /**
62      This method is normally used to just print the error message
63      passed as a parameter.
64   */

65   void error(String JavaDoc message);
66
67   /**
68      This method is invoked to handle the error.
69
70      @param message The message assoicated with the error.
71      @param e The Exption that was thrown when the error occured.
72      @param errorCode The error code associated with the error.
73      @param event The logging event that the failing appender is asked
74             to log.
75
76      @since 1.2 */

77   void error(String JavaDoc message, Exception JavaDoc e, int errorCode, LoggingEvent event);
78   
79   /**
80      Set the appender for which errors are handled. This method is
81      usually called when the error handler is configured.
82      
83      @since 1.2 */

84   void setAppender(Appender appender);
85
86   /**
87      Set the appender to falkback upon in case of failure.
88      
89      @since 1.2 */

90   void setBackupAppender(Appender appender);
91 }
92
Popular Tags