Class WriterManager
java.lang.Object
org.apache.logging.log4j.core.appender.AbstractManager
org.apache.logging.log4j.core.appender.WriterManager
- All Implemented Interfaces:
AutoCloseable
Manages a Writer so that it can be shared by multiple Appenders and will
allow appenders to reconfigure without requiring a new writer.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.logging.log4j.core.appender.AbstractManager
AbstractManager.AbstractFactoryData
-
Field Summary
Fields inherited from class org.apache.logging.log4j.core.appender.AbstractManager
count, LOGGER
-
Constructor Summary
ConstructorDescriptionWriterManager
(Writer writer, String streamName, StringLayout layout, boolean writeHeader) -
Method Summary
Modifier and TypeMethodDescriptionprotected void
void
flush()
Flushes any buffers.static <T> WriterManager
getManager
(String name, T data, ManagerFactory<? extends WriterManager, T> factory) Creates a Manager.protected Writer
boolean
isOpen()
Returns the status of the stream.boolean
releaseSub
(long timeout, TimeUnit timeUnit) Default hook to write footer during close.protected void
protected void
Some output streams synchronize writes while others do not.protected void
Writes the footer.Methods inherited from class org.apache.logging.log4j.core.appender.AbstractManager
close, getContentFormat, getCount, getLoggerContext, getManager, getName, getStrSubstitutor, hasManager, log, logDebug, logError, logger, logWarn, narrow, release, stop, updateData
-
Field Details
-
layout
-
-
Constructor Details
-
WriterManager
-
-
Method Details
-
getManager
public static <T> WriterManager getManager(String name, T data, ManagerFactory<? extends WriterManager, T> factory) Creates a Manager.- Type Parameters:
T
- The type of the WriterManager.- Parameters:
name
- The name of the stream to manage.data
- The data to pass to the Manager.factory
- The factory to use to create the Manager.- Returns:
- A WriterManager.
-
closeWriter
protected void closeWriter() -
flush
public void flush()Flushes any buffers. -
getWriter
-
isOpen
public boolean isOpen()Returns the status of the stream.- Returns:
- true if the stream is open, false if it is not.
-
releaseSub
Default hook to write footer during close.- Overrides:
releaseSub
in classAbstractManager
- Parameters:
timeout
- timeouttimeUnit
- timeout time unit- Returns:
- true if all resources were closed normally, false otherwise.
-
setWriter
-
write
Some output streams synchronize writes while others do not. Synchronizing here insures that log events won't be intertwined.- Parameters:
str
- the string to write- Throws:
AppenderLoggingException
- if an error occurs.
-