Closeable, Flushable, AutoCloseable, FlushableCloseableAsyncHandler, DelayedHandler, NullHandler, QueueHandler, SocketHandler, SyslogHandler, WriterHandlerpublic abstract class ExtHandler extends Handler implements FlushableCloseable
ExtLogRecord
instances.| Modifier and Type | Field | Description |
|---|---|---|
protected Handler[] |
handlers |
The sub-handlers for this handler.
|
protected static org.jboss.logmanager.AtomicArray<ExtHandler,Handler> |
handlersUpdater |
The atomic updater for the
handlers field. |
| Modifier | Constructor | Description |
|---|---|---|
protected |
ExtHandler() |
Construct a new instance.
|
| Modifier and Type | Method | Description |
|---|---|---|
void |
addHandler(Handler handler) |
Add a sub-handler to this handler.
|
Handler[] |
clearHandlers() |
A convenience method to atomically get and clear all sub-handlers.
|
void |
close() |
Close all child handlers.
|
protected void |
doPublish(ExtLogRecord record) |
Do the actual work of publication; the record will have been filtered already.
|
void |
flush() |
Flush all child handlers.
|
Handler[] |
getHandlers() |
Get a copy of the sub-handlers array.
|
boolean |
isAutoFlush() |
Determine if this handler will auto-flush.
|
boolean |
isCallerCalculationRequired() |
Indicates whether or not the formatter associated with this handler or a formatter
from a child handler requires the caller to be calculated.
|
boolean |
isCloseChildren() |
Indicates whether or not children handlers should be closed when this handler is closed.
|
boolean |
isEnabled() |
Determine if the handler is enabled.
|
void |
publish(LogRecord record) |
|
void |
publish(ExtLogRecord record) |
Publish an
ExtLogRecord. |
protected void |
publishToNestedHandlers(ExtLogRecord record) |
Publish a log record to each nested handler.
|
void |
removeHandler(Handler handler) |
Remove a sub-handler from this handler.
|
protected void |
reportError(String msg,
Exception ex,
int code) |
|
static void |
reportError(Handler handler,
String msg,
Exception ex,
int code) |
Report an error using a handler's specific error manager, if any.
|
void |
setAutoFlush(boolean autoFlush) |
Change the autoflush setting for this handler.
|
void |
setCloseChildren(boolean closeChildren) |
Sets whether or not children handlers should be closed when this handler is closed.
|
void |
setEnabled(boolean enabled) |
Enables or disables the handler based on the value passed in.
|
void |
setEncoding(String encoding) |
|
void |
setErrorManager(ErrorManager em) |
|
void |
setFilter(Filter newFilter) |
|
void |
setFormatter(Formatter newFormatter) |
|
Handler[] |
setHandlers(Handler[] newHandlers) |
A convenience method to atomically get and replace the sub-handler array.
|
void |
setLevel(Level newLevel) |
getEncoding, getErrorManager, getFilter, getFormatter, getLevel, isLoggableprotected volatile Handler[] handlers
handlersUpdater atomic updater. The array
instance should not be modified (treat as immutable).protected static final org.jboss.logmanager.AtomicArray<ExtHandler,Handler> handlersUpdater
handlers field.public void publish(ExtLogRecord record)
ExtLogRecord.
The logging request was made initially to a Logger object, which initialized the LogRecord and forwarded it here.
The ExtHandler is responsible for formatting the message, when and if necessary. The formatting should
include localization.record - the log record to publishprotected void publishToNestedHandlers(ExtLogRecord record)
record - the log record to publishprotected void doPublish(ExtLogRecord record)
autoFlush property is set to true; if this behavior is to be
preserved in a subclass then this method should be called after the record is physically written.record - the log record to publishpublic void addHandler(Handler handler)
handler - the handler to addpublic void removeHandler(Handler handler) throws SecurityException
handler - the handler to removeSecurityExceptionpublic Handler[] getHandlers()
public Handler[] clearHandlers() throws SecurityException
SecurityExceptionpublic Handler[] setHandlers(Handler[] newHandlers) throws SecurityException
newHandlers - the new sub-handlersSecurityExceptionpublic boolean isAutoFlush()
true if auto-flush is enabledpublic void setAutoFlush(boolean autoFlush)
throws SecurityException
autoFlush - true to automatically flush after each write; false otherwiseSecurityExceptionpublic final void setEnabled(boolean enabled)
throws SecurityException
enabled - true to enable the handler or false to disable the handler.SecurityExceptionpublic final boolean isEnabled()
true if the handler is enabled, otherwise false.public boolean isCloseChildren()
true if the children handlers should be closed when this handler is closed, false if
children handlers should not be closed when this handler is closedpublic void setCloseChildren(boolean closeChildren)
closeChildren - true if all children handlers should be closed when this handler is closed,
false if children handlers will not be closed when this handler
is closedpublic void flush()
public void close()
throws SecurityException
close in interface AutoCloseableclose in interface Closeableclose in class HandlerSecurityExceptionpublic void setFormatter(Formatter newFormatter) throws SecurityException
setFormatter in class HandlerSecurityExceptionpublic void setFilter(Filter newFilter) throws SecurityException
setFilter in class HandlerSecurityExceptionpublic void setEncoding(String encoding) throws SecurityException, UnsupportedEncodingException
setEncoding in class HandlerSecurityExceptionUnsupportedEncodingExceptionpublic void setErrorManager(ErrorManager em)
setErrorManager in class Handlerpublic void setLevel(Level newLevel) throws SecurityException
setLevel in class HandlerSecurityExceptionpublic boolean isCallerCalculationRequired()
Calculating the caller on a log record can be an expensive operation. Some handlers
may be required to copy some data from the log record, but may not need the caller information. If the
formatter is a ExtFormatter the
ExtFormatter.isCallerCalculationRequired() is used to determine if calculation of the caller is
required.
true if the caller should be calculated, otherwise false if it can be skippedLogRecord.getSourceClassName(),
ExtLogRecord.getSourceFileName(),
ExtLogRecord.getSourceLineNumber(),
LogRecord.getSourceMethodName()protected void reportError(String msg, Exception ex, int code)
reportError in class HandlerCopyright © 2020 JBoss by Red Hat. All rights reserved.