1 *java.util.logging.StreamHandler* *StreamHandler* Stream based logging Handler.
3 public class StreamHandler
4 extends |java.util.logging.Handler|
6 |java.util.logging.StreamHandler_Description|
7 |java.util.logging.StreamHandler_Fields|
8 |java.util.logging.StreamHandler_Constructors|
9 |java.util.logging.StreamHandler_Methods|
11 ================================================================================
13 *java.util.logging.StreamHandler_Constructors*
14 |java.util.logging.StreamHandler()|Create a StreamHandler, with no current outp
15 |java.util.logging.StreamHandler(OutputStream,Formatter)|Create a StreamHandler
17 *java.util.logging.StreamHandler_Methods*
18 |java.util.logging.StreamHandler.close()|Close the current output stream.
19 |java.util.logging.StreamHandler.flush()|Flush any buffered messages.
20 |java.util.logging.StreamHandler.isLoggable(LogRecord)|Check if this Handler wo
21 |java.util.logging.StreamHandler.publish(LogRecord)|Format and publish a LogRec
22 |java.util.logging.StreamHandler.setEncoding(String)|Set (or change) the charac
23 |java.util.logging.StreamHandler.setOutputStream(OutputStream)|Change the outpu
25 *java.util.logging.StreamHandler_Description*
27 Stream based logging Handler.
29 This is primarily intended as a base class or support class to be used in
30 implementing other logging Handlers.
32 LogRecords are published to a given java.io.OutputStream.
34 Configuration: By default each StreamHandler is initialized using the following
35 LogManager configuration properties. If properties are not defined (or have
36 invalid values) then the specified default values are used.
38 java.util.logging.StreamHandler.level specifies the default level for the
39 Handler (defaults to Level.INFO). java.util.logging.StreamHandler.filter
40 specifies the name of a Filter class to use (defaults to no Filter).
41 java.util.logging.StreamHandler.formatter specifies the name of a Formatter
42 class to use (defaults to java.util.logging.SimpleFormatter).
43 java.util.logging.StreamHandler.encoding the name of the character set encoding
44 to use (defaults to the default platform encoding).
47 *java.util.logging.StreamHandler()*
49 public StreamHandler()
51 Create a StreamHandler, with no current output stream.
54 *java.util.logging.StreamHandler(OutputStream,Formatter)*
57 java.io.OutputStream out,
58 java.util.logging.Formatter formatter)
60 Create a StreamHandler with a given Formatter and output stream.
62 out - the target output stream
63 formatter - Formatter to be used to format output
65 *java.util.logging.StreamHandler.close()*
67 public synchronized void close()
68 throws |java.lang.SecurityException|
70 Close the current output stream.
72 The Formatter's "tail" string is written to the stream before it is closed. In
73 addition, if the Formatter's "head" string has not yet been written to the
74 stream, it will be written before the "tail" string.
77 *java.util.logging.StreamHandler.flush()*
79 public synchronized void flush()
81 Flush any buffered messages.
84 *java.util.logging.StreamHandler.isLoggable(LogRecord)*
86 public boolean isLoggable(java.util.logging.LogRecord record)
88 Check if this Handler would actually log a given LogRecord.
90 This method checks if the LogRecord has an appropriate level and whether it
91 satisfies any Filter. It will also return false if no output stream has been
92 assigned yet or the LogRecord is Null.
96 Returns: true if the LogRecord would be logged.
97 *java.util.logging.StreamHandler.publish(LogRecord)*
99 public synchronized void publish(java.util.logging.LogRecord record)
101 Format and publish a LogRecord.
103 The StreamHandler first checks if there is an OutputStream and if the given
104 LogRecord has at least the required log level. If not it silently returns. If
105 so, it calls any associated Filter to check if the record should be published.
106 If so, it calls its Formatter to format the record and then writes the result
107 to the current output stream.
109 If this is the first LogRecord to be written to a given OutputStream, the
110 Formatter's "head" string is written to the stream before the LogRecord is
113 record - description of the log event. A null record is silently ignored and is not
116 *java.util.logging.StreamHandler.setEncoding(String)*
118 public void setEncoding(java.lang.String encoding)
119 throws |java.lang.SecurityException|
120 |java.io.UnsupportedEncodingException|
122 Set (or change) the character encoding used by this Handler.
124 The encoding should be set before any LogRecords are written to the Handler.
126 encoding - The name of a supported character encoding. May be null, to indicate the
127 default platform encoding.
129 *java.util.logging.StreamHandler.setOutputStream(OutputStream)*
131 protected synchronized void setOutputStream(java.io.OutputStream out)
132 throws |java.lang.SecurityException|
134 Change the output stream.
136 If there is a current output stream then the Formatter's tail string is written
137 and the stream is flushed and closed. Then the output stream is replaced with
138 the new output stream.
140 out - New output stream. May not be null.