java.lang.Object
java.util.logging.Handler
org.jboss.logmanager.ExtHandler
org.jboss.logmanager.handlers.WriterHandler
- All Implemented Interfaces:
Flushable,AutoCloseable
- Direct Known Subclasses:
OutputStreamHandler
A handler which writes to any
Writer.-
Field Summary
Fields inherited from class org.jboss.logmanager.ExtHandler
handlers, handlersUpdater, lock -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Close this logger.protected voiddoPublish(ExtLogRecord record) Do the actual work of publication; the record will have been filtered already.voidflush()Flush this logger.booleanDetermine whether head encoding checking is turned on.booleanDetermine whether tail encoding checking is turned on.protected voidpreWrite(ExtLogRecord record) Execute any pre-write policy, such as file rotation.protected voidSafely close the resource, reporting an error if the close fails.setCheckHeadEncoding(boolean checkHeadEncoding) Establish whether head encoding checking is turned on.setCheckTailEncoding(boolean checkTailEncoding) Establish whether tail encoding checking is turned on.voidSet the writer.Methods inherited from class org.jboss.logmanager.ExtHandler
addHandler, checkAccess, checkAccess, clearHandlers, getCharset, getEncoding, getErrorManager, getFilter, getFormatter, getHandlers, getLevel, isAutoFlush, isCallerCalculationRequired, isCloseChildren, isEnabled, publish, publish, publishToNestedHandlers, removeHandler, reportError, reportError, setAutoFlush, setCharset, setCharsetPrivate, setCloseChildren, setEnabled, setEncoding, setErrorManager, setFilter, setFormatter, setHandlers, setLevelMethods inherited from class java.util.logging.Handler
isLoggable
-
Constructor Details
-
WriterHandler
public WriterHandler()Construct a new instance.
-
-
Method Details
-
doPublish
Do the actual work of publication; the record will have been filtered already. The default implementation does nothing except to flush if theautoFlushproperty is set totrue; if this behavior is to be preserved in a subclass then this method should be called after the record is physically written.- Overrides:
doPublishin classExtHandler- Parameters:
record- the log record to publish
-
preWrite
Execute any pre-write policy, such as file rotation. The write lock is held during this method, so make it quick. The default implementation does nothing.- Parameters:
record- the record about to be logged
-
setWriter
Set the writer. The writer will then belong to this handler; when the handler is closed or a new writer is set, this writer will be closed.- Parameters:
writer- the new writer, ornullto disable logging
-
isCheckHeadEncoding
public boolean isCheckHeadEncoding()Determine whether head encoding checking is turned on.- Returns:
trueto check and report head encoding problems, orfalseto ignore them
-
setCheckHeadEncoding
Establish whether head encoding checking is turned on.- Parameters:
checkHeadEncoding-trueto check and report head encoding problems, orfalseto ignore them- Returns:
- this handler
-
isCheckTailEncoding
public boolean isCheckTailEncoding()Determine whether tail encoding checking is turned on.- Returns:
trueto check and report tail encoding problems, orfalseto ignore them
-
setCheckTailEncoding
Establish whether tail encoding checking is turned on.- Parameters:
checkTailEncoding-trueto check and report tail encoding problems, orfalseto ignore them- Returns:
- this handler
-
flush
public void flush()Flush this logger.- Specified by:
flushin interfaceFlushable- Overrides:
flushin classExtHandler
-
close
Close this logger.- Specified by:
closein interfaceAutoCloseable- Overrides:
closein classExtHandler- Throws:
SecurityException- if the caller does not have sufficient permission
-
safeClose
Safely close the resource, reporting an error if the close fails.- Parameters:
c- the resource
-