1 *java.util.logging.Handler* *Handler* A Handler object takes log messages from a
3 public abstract class Handler
4 extends |java.lang.Object|
6 |java.util.logging.Handler_Description|
7 |java.util.logging.Handler_Fields|
8 |java.util.logging.Handler_Constructors|
9 |java.util.logging.Handler_Methods|
11 ================================================================================
13 *java.util.logging.Handler_Constructors*
14 |java.util.logging.Handler()|Default constructor.
16 *java.util.logging.Handler_Methods*
17 |java.util.logging.Handler.close()|Close the Handler and free all associated re
18 |java.util.logging.Handler.flush()|Flush any buffered output.
19 |java.util.logging.Handler.getEncoding()|Return the character encoding for this
20 |java.util.logging.Handler.getErrorManager()|Retrieves the ErrorManager for thi
21 |java.util.logging.Handler.getFilter()|Get the current Filter for this Handler.
22 |java.util.logging.Handler.getFormatter()|Return the Formatter for this Handler
23 |java.util.logging.Handler.getLevel()|Get the log level specifying which messag
24 |java.util.logging.Handler.isLoggable(LogRecord)|Check if this Handler would ac
25 |java.util.logging.Handler.publish(LogRecord)|Publish a LogRecord.
26 |java.util.logging.Handler.reportError(String,Exception,int)|Protected convenie
27 |java.util.logging.Handler.setEncoding(String)|Set the character encoding used
28 |java.util.logging.Handler.setErrorManager(ErrorManager)|Define an ErrorManager
29 |java.util.logging.Handler.setFilter(Filter)|Set a Filter to control output on
30 |java.util.logging.Handler.setFormatter(Formatter)|Set a Formatter.
31 |java.util.logging.Handler.setLevel(Level)|Set the log level specifying which m
33 *java.util.logging.Handler_Description*
35 A Handler object takes log messages from a Logger and exports them. It might
36 for example, write them to a console or write them to a file, or send them to a
37 network logging service, or forward them to an OS log, or whatever.
39 A Handler can be disabled by doing a setLevel(Level.OFF) and can be re-enabled
40 by doing a setLevel with an appropriate level.
42 Handler classes typically use LogManager properties to set default values for
43 the Handler's Filter, Formatter, and Level. See the specific documentation for
44 each concrete Handler class.
48 *java.util.logging.Handler()*
52 Default constructor. The resulting Handler has a log level of Level.ALL, no
53 Formatter, and no Filter. A default ErrorManager instance is installed as the
57 *java.util.logging.Handler.close()*
59 public abstract void close()
60 throws |java.lang.SecurityException|
62 Close the Handler and free all associated resources.
64 The close method will perform a flush and then close the Handler. After close
65 has been called this Handler should no longer be used. Method calls may either
66 be silently ignored or may throw runtime exceptions.
70 *java.util.logging.Handler.flush()*
72 public abstract void flush()
74 Flush any buffered output.
78 *java.util.logging.Handler.getEncoding()*
80 public |java.lang.String| getEncoding()
82 Return the character encoding for this Handler.
86 Returns: The encoding name. May be null, which indicates the default encoding should be
89 *java.util.logging.Handler.getErrorManager()*
91 public |java.util.logging.ErrorManager| getErrorManager()
93 Retrieves the ErrorManager for this Handler.
97 *java.util.logging.Handler.getFilter()*
99 public |java.util.logging.Filter| getFilter()
101 Get the current Filter for this Handler.
105 Returns: a Filter object (may be null)
107 *java.util.logging.Handler.getFormatter()*
109 public |java.util.logging.Formatter| getFormatter()
111 Return the Formatter for this Handler.
115 Returns: the Formatter (may be null).
117 *java.util.logging.Handler.getLevel()*
119 public synchronized |java.util.logging.Level| getLevel()
121 Get the log level specifying which messages will be logged by this Handler.
122 Message levels lower than this level will be discarded.
126 Returns: the level of messages being logged.
128 *java.util.logging.Handler.isLoggable(LogRecord)*
130 public boolean isLoggable(java.util.logging.LogRecord record)
132 Check if this Handler would actually log a given LogRecord.
134 This method checks if the LogRecord has an appropriate Level and whether it
135 satisfies any Filter. It also may make other Handler specific checks that might
136 prevent a handler from logging the LogRecord. It will return false if the
142 Returns: true if the LogRecord would be logged.
144 *java.util.logging.Handler.publish(LogRecord)*
146 public abstract void publish(java.util.logging.LogRecord record)
150 The logging request was made initially to a Logger object, which initialized
151 the LogRecord and forwarded it here.
153 The Handler is responsible for formatting the message, when and if necessary.
154 The formatting should include localization.
157 record - description of the log event. A null record is silently ignored and is not
160 *java.util.logging.Handler.reportError(String,Exception,int)*
162 protected void reportError(
163 java.lang.String msg,
164 java.lang.Exception ex,
167 Protected convenience method to report an error to this Handler's ErrorManager.
168 Note that this method retrieves and uses the ErrorManager without doing a
169 security check. It can therefore be used in environments where the caller may
173 msg - a descriptive string (may be null)
174 ex - an exception (may be null)
175 code - an error code defined in ErrorManager
177 *java.util.logging.Handler.setEncoding(String)*
179 public void setEncoding(java.lang.String encoding)
180 throws |java.lang.SecurityException|
181 |java.io.UnsupportedEncodingException|
183 Set the character encoding used by this Handler.
185 The encoding should be set before any LogRecords are written to the Handler.
188 encoding - The name of a supported character encoding. May be null, to indicate the
189 default platform encoding.
191 *java.util.logging.Handler.setErrorManager(ErrorManager)*
193 public void setErrorManager(java.util.logging.ErrorManager em)
195 Define an ErrorManager for this Handler.
197 The ErrorManager's "error" method will be invoked if any errors occur while
201 em - the new ErrorManager
203 *java.util.logging.Handler.setFilter(Filter)*
205 public void setFilter(java.util.logging.Filter newFilter)
206 throws |java.lang.SecurityException|
208 Set a Filter to control output on this Handler.
210 For each call of publish the Handler will call this Filter (if it is non-null)
211 to check if the LogRecord should be published or discarded.
214 newFilter - a Filter object (may be null)
216 *java.util.logging.Handler.setFormatter(Formatter)*
218 public void setFormatter(java.util.logging.Formatter newFormatter)
219 throws |java.lang.SecurityException|
221 Set a Formatter. This Formatter will be used to format LogRecords for this
224 Some Handlers may not use Formatters, in which case the Formatter will be
225 remembered, but not used.
228 newFormatter - the Formatter to use (may not be null)
230 *java.util.logging.Handler.setLevel(Level)*
232 public synchronized void setLevel(java.util.logging.Level newLevel)
233 throws |java.lang.SecurityException|
235 Set the log level specifying which message levels will be logged by this
236 Handler. Message levels lower than this value will be discarded.
238 The intention is to allow developers to turn on voluminous logging, but to
239 limit the messages that are sent to certain Handlers.
242 newLevel - the new value for the log level