Class ConsoleHandler

java.lang.Object
java.util.logging.Handler
java.util.logging.StreamHandler
org.rapidcontext.util.logging.ConsoleHandler

public class ConsoleHandler extends StreamHandler
A console log handler that separates output streams based on log level. Error and warning level messages are sent to stderr, while info and lower level messages are sent to stdout.

Configured by the following properties:

  • [class-name].level -- a minimum log level (Level.ALL)
  • [class-name].filter -- an optional log filter (none)
  • [class-name].formatter -- a log formatter (org.rapidcontext.util.logging.LogFormatter)
  • [class-name].encoding -- an optional encoding (platform default)
  • [class-name].stderr-level -- the minimum level for stderr output (Level.WARNING)
  • Field Details

    • errorLevel

      protected Level errorLevel
      The minimum level for stderr output. Default is Level.WARNING.
  • Constructor Details

    • ConsoleHandler

      public ConsoleHandler()
      Creates a new log console handler using LogManager configuration properties.
    • ConsoleHandler

      public ConsoleHandler(Level errorLevel)
      Creates a new log console handler.
      Parameters:
      errorLevel - the minimum level for stderr output
  • Method Details

    • close

      public void close() throws SecurityException
      Closes this handler and releases any associated resources.
      Overrides:
      close in class StreamHandler
      Throws:
      SecurityException - if logging control permission is missing
    • flush

      public void flush()
      Flushes any buffered output.
      Overrides:
      flush in class StreamHandler
    • publish

      public void publish(LogRecord record)
      Formats and publishes a log record to the appropriate output stream.
      Overrides:
      publish in class StreamHandler
      Parameters:
      record - the log entry to publish
      Throws:
      SecurityException - if the log stream couldn't be modified
    • setErrorStream

      protected void setErrorStream(OutputStream err)
      Sets the error output stream.
      Parameters:
      err - the output stream