1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.log4j.spi;
19
20 import org.apache.log4j.Appender;
21 import org.apache.log4j.Logger;
22
23
24 /***
25 Appenders may delegate their error handling to
26 <code>ErrorHandlers</code>.
27
28 <p>Error handling is a particularly tedious to get right because by
29 definition errors are hard to predict and to reproduce.
30
31
32 <p>Please take the time to contact the author in case you discover
33 that errors are not properly handled. You are most welcome to
34 suggest new error handling policies or criticize existing policies.
35
36
37 @author Ceki Gülcü
38
39 */
40 public interface ErrorHandler extends OptionHandler {
41
42 /***
43 Add a reference to a logger to which the failing appender might
44 be attached to. The failing appender will be searched and
45 replaced only in the loggers you add through this method.
46
47 @param logger One of the loggers that will be searched for the failing
48 appender in view of replacement.
49
50 @since 1.2 */
51 void setLogger(Logger logger);
52
53
54 /***
55 Equivalent to the {@link #error(String, Exception, int,
56 LoggingEvent event)} with the the event parameteter set to
57 <code>null</code>.
58
59 */
60 void error(String message, Exception e, int errorCode);
61
62 /***
63 This method is normally used to just print the error message
64 passed as a parameter.
65 */
66 void error(String message);
67
68 /***
69 This method is invoked to handle the error.
70
71 @param message The message assoicated with the error.
72 @param e The Exption that was thrown when the error occured.
73 @param errorCode The error code associated with the error.
74 @param event The logging event that the failing appender is asked
75 to log.
76
77 @since 1.2 */
78 void error(String message, Exception e, int errorCode, LoggingEvent event);
79
80 /***
81 Set the appender for which errors are handled. This method is
82 usually called when the error handler is configured.
83
84 @since 1.2 */
85 void setAppender(Appender appender);
86
87 /***
88 Set the appender to falkback upon in case of failure.
89
90 @since 1.2 */
91 void setBackupAppender(Appender appender);
92 }