public class LogWindowHandler extends Handler
From the book "Logging in Java with the JDK 1.4 Logging API and Apache log4j"
This is a Custom Handler object which publishes its logging information to a separate Java window. This follows a singleton pattern to maintain the writing of logging information to the same window as opposed to writing it by opening a new window each time.
An application can potentially try to obtain an instance of this Handler at serveral places. Each such attempt will generate a new window. To avoid that a single instance is provided per application with the getInstance() method.
Constructor | Description |
---|---|
LogWindowHandler() |
don't call this except in logging.properties, or one would get
multiple windows
|
Modifier and Type | Method | Description |
---|---|---|
void |
close() |
|
void |
flush() |
|
static LogWindowHandler |
getInstance() |
The getInstane method returns the singleton instance of the WindowHandler
object It is synchronized to prevent two threads trying to crate an
instance simultaneously.
|
LogWindow |
getWindow() |
|
void |
publish(LogRecord record) |
Publish record to window.
|
getEncoding, getErrorManager, getFilter, getFormatter, getLevel, isLoggable, reportError, setEncoding, setErrorManager, setFilter, setFormatter, setLevel
public LogWindowHandler()
public static LogWindowHandler getInstance()
public void publish(LogRecord record)
This is the overridden publish method of the abstract super class Handler. This method writes the logging information to the associated Java window. This method is synchronized to make it thread-safe. In case, there is a problem, it reports the problem with the ErrorManager, only once and silently ignores the others.
public LogWindow getWindow()
Copyright © 2010-2018 Nikhef / Stichting FOM. All Rights Reserved.