Class WriterManager

java.lang.Object
org.apache.logging.log4j.core.appender.AbstractManager
org.apache.logging.log4j.core.appender.WriterManager
All Implemented Interfaces:
AutoCloseable

public class WriterManager extends AbstractManager
Manages a Writer so that it can be shared by multiple Appenders and will allow appenders to reconfigure without requiring a new writer.
  • Field Details

  • Constructor Details

  • 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

      protected Writer getWriter()
    • isOpen

      public boolean isOpen()
      Returns the status of the stream.
      Returns:
      true if the stream is open, false if it is not.
    • releaseSub

      public boolean releaseSub(long timeout, TimeUnit timeUnit)
      Default hook to write footer during close.
      Overrides:
      releaseSub in class AbstractManager
      Parameters:
      timeout - timeout
      timeUnit - timeout time unit
      Returns:
      true if all resources were closed normally, false otherwise.
    • setWriter

      protected void setWriter(Writer writer)
    • write

      protected void write(String str)
      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.
    • writeFooter

      protected void writeFooter()
      Writes the footer.