Class TLcdJULSimpleFormatter

java.lang.Object
java.util.logging.Formatter
com.luciad.util.logging.TLcdJULSimpleFormatter

public class TLcdJULSimpleFormatter extends Formatter
A formatter for LogRecord messages. The following properties of a LogRecord are used as the argument list to the String.format(String, Object...) method:
  1. LogRecord.getMessage()
  2. LogRecord.getLoggerName()
  3. LogRecord.getLevel()
  4. LogRecord.getMillis() as a Date object
  5. LogRecord.getSourceClassName()
  6. LogRecord.getSourceMethodName()
  7. LogRecord.getThreadID()
  8. LogRecord.getThrown()
The format string get be set either directly from the setter, or by defining the property com.luciad.util.logging.TLcdJULSimpleFormatter.format in the Java logging properties file.

When the LogRecord contains a Throwable object the corresponding stack trace is also logged immediately after the message. To disable logging of the stack trace you can set the property com.luciad.util.logging.TLcdJULSimpleFormatter.logStackTrace to false

For example, the following two configuration lines:


 java.util.logging.ConsoleHandler.formatter = com.luciad.util.logging.TLcdJULSimpleFormatter
 com.luciad.util.logging.TLcdJULSimpleFormatter.format = %3$s: %1$s (%8$s)\n
 com.luciad.util.logging.TLcdJULSimpleFormatter.logStackTrace = false
 
may display a log message as "SEVERE: An exception occurred (ArrayIndexOutOfBoundsException)". It will not display the stack trace.
Since:
9.0
See Also:
  • Constructor Details

    • TLcdJULSimpleFormatter

      public TLcdJULSimpleFormatter()
      Default constructor.
  • Method Details

    • getFormat

      public String getFormat()
      Returns the log format string.
      Returns:
      the format string.
    • setFormat

      public void setFormat(String aFormat)
      Sets the log format string
      Parameters:
      aFormat - the format string
    • format

      public String format(LogRecord aRecord)
      Specified by:
      format in class Formatter
    • isLogStackTrace

      public boolean isLogStackTrace()
      Returns true if the stack of Throwable objects is logged, false otherwise.
      Returns:
      true if the stack of Throwable objects is logged, false otherwise.
    • setLogStackTrace

      public void setLogStackTrace(boolean aLogStackTrace)
      Sets the value of the logStackTrace property.
      Parameters:
      aLogStackTrace - if true (default), stack traces are logged.