Class TLcdJULFileHandler

java.lang.Object
java.util.logging.Handler
com.luciad.util.logging.TLcdJULFileHandler

public class TLcdJULFileHandler extends Handler
A Handler that logs all messages to a file. This class is similar to the standard FileHandler but it can be used by any number of Loggers.

The TLcdJULFileHandler maintains a list of several log files. The current (most recent) file has the index 0 while older logs have corresponding increasing numbers. When the size of the current log file exceeds a certain limit, the log files are rotated. The total number of log files is also limited - if the limit is exceeded then the oldest file is deleted.

The first time a handler of this type is created, it reads the following properties from the logging configuration file:

  • com.luciad.util.logging.TLcdJULFileHandler.level specifies the level of this Handler. The default is Level.INFO.
  • com.luciad.util.logging.TLcdJULFileHandler.filter specifies the name of a Filter class. The default is no filter.
  • com.luciad.util.logging.TLcdJULFileHandler.formatter specifies the name of a Formatter class. The default is TLcdSimpleFomratter.
  • com.luciad.util.logging.TLcdJULFileHandler.encoding specifies the name of the character set encoding. If not specified, the default platform encoding is used.
  • com.luciad.util.logging.TLcdJULFileHandler.limit specifies the approximate maximum size of a log file in bytes. The default is 1 MByte.
  • com.luciad.util.logging.TLcdJULFileHandler.count specifies how many log files should be kept. If this number is exceeded, the oldest file is deleted. The default value is 5.
  • com.luciad.util.logging.TLcdJULFileHandler.pattern specifies the pattern for generating the output file name (see below). The default is "%h/java%g.log".
  • com.luciad.util.logging.TLcdJULFileHandler.append specifies whether the handler should append to any existing log file or to rotate the logs when the application starts. The default is false, meaning that the logs are rotated and a new file is created.

A pattern consists of a string that includes the following special components that will be replaced at runtime:

  • "/" the local pathname separator.
  • "%t" the system temporary directory.
  • "%h" the value of the "user.home" system property.
  • "%g" the generation number to distinguish rotated logs. The current (most recent) log has index 0.
  • "%%" translates to a single percent sign "%".
If the directory containing the log file does not exist, it is automatically created.
Since:
9.0
  • Constructor Details

    • TLcdJULFileHandler

      public TLcdJULFileHandler()
      Creates a new TLcdJULFileHandler with the default settings.
  • Method Details

    • publish

      public void publish(LogRecord aRecord)
      Writes the given LogRecord to the log. The file is flushed after each log record.
      Specified by:
      publish in class Handler
      Parameters:
      aRecord - the record to write.
    • flush

      public void flush()
      Flushes any buffered message.
      Specified by:
      flush in class Handler
    • close

      public void close() throws SecurityException
      Closes the stream of the current TLcdJULFileHandler..
      Specified by:
      close in class Handler
      Throws:
      SecurityException